change diff order to -want +got
This is easier to read and consistent with how we do things at work.
This commit is contained in:
parent
414a7c025b
commit
c0067c5aa5
@ -166,8 +166,8 @@ func TestDHCPv4(t *testing.T) {
|
|||||||
trimSpace := func(line string) string {
|
trimSpace := func(line string) string {
|
||||||
return strings.TrimSpace(line)
|
return strings.TrimSpace(line)
|
||||||
}
|
}
|
||||||
if !cmp.Equal(got, want, cmp.Transformer("TrimSpace", trimSpace)) {
|
if !cmp.Equal(want, got, cmp.Transformer("TrimSpace", trimSpace)) {
|
||||||
t.Errorf("dnsmasq log does not contain expected DHCP sequence: diff (-got +want):\n%s",
|
t.Errorf("dnsmasq log does not contain expected DHCP sequence: diff (-want +got):\n%s",
|
||||||
diff.LineDiff(
|
diff.LineDiff(
|
||||||
strings.Join(diff.TrimLines(got), "\n"),
|
strings.Join(diff.TrimLines(got), "\n"),
|
||||||
strings.Join(diff.TrimLines(want), "\n")))
|
strings.Join(diff.TrimLines(want), "\n")))
|
||||||
|
@ -113,8 +113,8 @@ func TestDHCPv6(t *testing.T) {
|
|||||||
want := dhcp6.Config{
|
want := dhcp6.Config{
|
||||||
DNS: []string{"2001:db8::1"},
|
DNS: []string{"2001:db8::1"},
|
||||||
}
|
}
|
||||||
if diff := cmp.Diff(got, want); diff != "" {
|
if diff := cmp.Diff(want, got); diff != "" {
|
||||||
t.Fatalf("unexpected config: diff (-got +want):\n%s", diff)
|
t.Fatalf("unexpected config: diff (-want +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Release()
|
c.Release()
|
||||||
@ -132,8 +132,8 @@ func TestDHCPv6(t *testing.T) {
|
|||||||
withoutMac := func(line string) string {
|
withoutMac := func(line string) string {
|
||||||
return v6AddrRe.ReplaceAllString(strings.TrimSpace(line), "")
|
return v6AddrRe.ReplaceAllString(strings.TrimSpace(line), "")
|
||||||
}
|
}
|
||||||
if diff := cmp.Diff(got, want, cmp.Transformer("WithoutMAC", withoutMac)); diff != "" {
|
if diff := cmp.Diff(want, got, cmp.Transformer("WithoutMAC", withoutMac)); diff != "" {
|
||||||
t.Errorf("dnsmasq log does not contain expected DHCP sequence: diff (-got +want):\n%s", diff)
|
t.Errorf("dnsmasq log does not contain expected DHCP sequence: diff (-want +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -356,8 +356,8 @@ func TestNetconfig(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if diff := cmp.Diff(routes, wantRoutes); diff != "" {
|
if diff := cmp.Diff(wantRoutes, routes); diff != "" {
|
||||||
t.Fatalf("routes: diff (-got +want):\n%s", diff)
|
t.Fatalf("routes: diff (-want +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -419,8 +419,8 @@ peer: AVU3LodtnFaFnJmMyNNW7cUk4462lqnVULTFkjWYvRo=
|
|||||||
}
|
}
|
||||||
|
|
||||||
got := strings.Join(rules, "\n")
|
got := strings.Join(rules, "\n")
|
||||||
if diff := cmp.Diff(got, goldenNftablesRules(false), opts...); diff != "" {
|
if diff := cmp.Diff(goldenNftablesRules(false), got, opts...); diff != "" {
|
||||||
t.Fatalf("unexpected nftables rules: diff (-got +want):\n%s", diff)
|
t.Fatalf("unexpected nftables rules: diff (-want +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ Retransmit time : unspecified (0x00000000)
|
|||||||
Source link-layer address: 02:73:53:00:CA:FE
|
Source link-layer address: 02:73:53:00:CA:FE
|
||||||
from fe80::73:53ff:fe00:cafe
|
from fe80::73:53ff:fe00:cafe
|
||||||
`
|
`
|
||||||
if diff := cmp.Diff(got, want); diff != "" {
|
if diff := cmp.Diff(want, got); diff != "" {
|
||||||
t.Fatalf("unexpected rdisc6 output: diff (-got +want):\n%s", diff)
|
t.Fatalf("unexpected rdisc6 output: diff (-want +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ func TestDHCP4(t *testing.T) {
|
|||||||
"213.144.129.20",
|
"213.144.129.20",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if diff := cmp.Diff(got, want); diff != "" {
|
if diff := cmp.Diff(want, got); diff != "" {
|
||||||
t.Fatalf("unexpected config: diff (-got +want):\n%s", diff)
|
t.Fatalf("unexpected config: diff (-want +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ func TestSerialize(t *testing.T) {
|
|||||||
if err := json.Unmarshal(b, &got); err != nil {
|
if err := json.Unmarshal(b, &got); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if diff := cmp.Diff(got, want); diff != "" {
|
if diff := cmp.Diff(want, got); diff != "" {
|
||||||
t.Fatalf("unexpected config: diff (-got +want):\n%s", diff)
|
t.Fatalf("unexpected config: diff (-want +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,8 +73,8 @@ func TestDHCP6(t *testing.T) {
|
|||||||
"2001:1620:2777:2::20",
|
"2001:1620:2777:2::20",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if diff := cmp.Diff(got, want); diff != "" {
|
if diff := cmp.Diff(want, got); diff != "" {
|
||||||
t.Fatalf("unexpected config: diff (-got +want):\n%s", diff)
|
t.Fatalf("unexpected config: diff (-want +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ func TestDiagMonitor(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if diff := cmp.Diff(got, want); diff != "" {
|
if diff := cmp.Diff(want, got); diff != "" {
|
||||||
t.Fatalf("Evaluate(): unexpected result: diff (-got +want):\n%s", diff)
|
t.Fatalf("Evaluate(): unexpected result: diff (-want +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ func Example(t *testing.T) {
|
|||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
if diff := cmp.Diff(got, want, cmp.Transformer("ActionOnly", actionOnly)); diff != "" {
|
if diff := cmp.Diff(want, got, cmp.Transformer("ActionOnly", actionOnly)); diff != "" {
|
||||||
t.Errorf("dnsmasq log does not contain expected DHCP sequence: diff (-got +want):\n%s", diff)
|
t.Errorf("dnsmasq log does not contain expected DHCP sequence: diff (-want +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user