Skip to content

Commit

Permalink
reducing code smell
Browse files Browse the repository at this point in the history
  • Loading branch information
rbarazzutti committed Aug 18, 2023
1 parent 6b52302 commit d257d0f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,30 +63,30 @@ func commandTest(_ *testing.T, args []string) (*app.Config, []byte, error) {
}

func TestCount(t *testing.T) {
config, _, err := commandTest(t, []string{"-c", "123", "www.google.com"})
config, _, err := commandTest(t, []string{"-c", "123", "www.google.ch"})
if err != nil || config.Count != 123 {
t.Fatal("Count parameter not taken in account")
}
}

func TestEnforceIPv6(t *testing.T) {
config, _, err := commandTest(t, []string{"-6", "www.google.com"})
config, _, err := commandTest(t, []string{"-6", "ipv6.google.com"})
if err != nil && config.IPProtocol != "ip6" {
t.Fatal("IPv6 parameter not taken in account")
}

}

func TestEnforceIPv4AndIPv6(t *testing.T) {
_, _, err := commandTest(t, []string{"-4", "-6", "www.google.com"})
_, _, err := commandTest(t, []string{"-4", "-6", "www.epfl.ch"})
if err == nil {
t.Fatal("IPv6 parameter not taken in account")
}

}

func TestExcessOfArguments(t *testing.T) {
_, _, err := commandTest(t, []string{"www.google.com", "www.wikipedia.com"})
_, _, err := commandTest(t, []string{"www.ietf.org", "www.wikipedia.org"})
if err == nil {
t.Fatal("only one non-flag argument can we used")
}
Expand Down
4 changes: 4 additions & 0 deletions net/sockettrace/adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ func TestInterceptionOfHTTPRequest(t *testing.T) {
ctxA := WithTrace(context.Background(),
&ConnTrace{
Read: func(i int) {
// ignored here
},
Write: func(i int) {
// ignored here
},
TCPStart: func() {
tcpStartedA = true
Expand All @@ -62,8 +64,10 @@ func TestInterceptionOfHTTPRequest(t *testing.T) {
ctxB := WithTrace(ctxA,
&ConnTrace{
Read: func(i int) {
// ignored here
},
Write: func(i int) {
// ignored here
},
TCPStart: func() {
tcpStartedB = true
Expand Down

0 comments on commit d257d0f

Please sign in to comment.