Skip to content

Commit

Permalink
do not use google.com in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
boratanrikulu committed Jul 27, 2024
1 parent d1093d6 commit 5a92731
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion cmd/durdur/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import (
"github.com/urfave/cli/v2"
)

func writeLn(c *cli.Context, format string, a ...any) error {
return write(c, format+"\n", a...)
}

func write(c *cli.Context, format string, a ...any) error {
_, err := io.WriteString(c.App.Writer, fmt.Sprintf(format, a...))
return err
Expand All @@ -19,5 +23,5 @@ func marshalAndWrite(c *cli.Context, list any) error {
return fmt.Errorf("marshal src list: %w", err)
}

return write(c, string(b))
return writeLn(c, string(b))
}
8 changes: 4 additions & 4 deletions internal/ebpf/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ func TestList(t *testing.T) {
c.Run("list ip and dns", func(c *qt.C) {
newTWrap().Run(c, "attach", func(e *EBPF) {
c.Assert(e.DropSrc(tSrcIP), qt.IsNil)
c.Assert(e.DropDNS("bora.sh", "google.com"), qt.IsNil)
c.Assert(e.DropDNS("bora.sh", "quik.bora.sh"), qt.IsNil)

srcList, err := e.ListDNS()
c.Assert(err, qt.IsNil)
c.Assert(srcList, qt.HasLen, 2)
c.Assert(srcList, qt.DeepEquals, map[string]int{
"bora.sh": 0,
"google.com": 0,
"bora.sh": 0,
"quik.bora.sh": 0,
})

TDNSLookup(c, "bora.sh", false)
Expand All @@ -50,7 +50,7 @@ func TestList(t *testing.T) {
c.Assert(err, qt.IsNil)
c.Assert(srcList, qt.HasLen, 2)
c.Assert(srcList["bora.sh"], qt.Not(qt.Equals), 0)
c.Assert(srcList["google.com"], qt.Equals, 0)
c.Assert(srcList["quik.bora.sh"], qt.Equals, 0)

srcList, err = e.ListSrc()
c.Assert(err, qt.IsNil)
Expand Down

0 comments on commit 5a92731

Please sign in to comment.