diff --git a/libnetwork/firewall_linux_test.go b/libnetwork/firewall_linux_test.go index 771ffe9740..c33146a8f0 100644 --- a/libnetwork/firewall_linux_test.go +++ b/libnetwork/firewall_linux_test.go @@ -11,6 +11,7 @@ import ( "github.com/docker/docker/libnetwork/options" "github.com/docker/docker/libnetwork/testutils" "gotest.tools/v3/assert" + is "gotest.tools/v3/assert/cmp" ) const ( @@ -63,8 +64,8 @@ func TestUserChain(t *testing.T) { defer c.Stop() // init. condition, FORWARD chain empty DOCKER-USER not exist - assert.DeepEqual(t, getRules(t, iptables.IPv4, fwdChainName), []string{"-P FORWARD ACCEPT"}) - assert.DeepEqual(t, getRules(t, iptables.IPv6, fwdChainName), []string{"-P FORWARD ACCEPT"}) + assert.Check(t, is.DeepEqual(getRules(t, iptable4, fwdChainName), []string{"-P FORWARD ACCEPT"})) + assert.Check(t, is.DeepEqual(getRules(t, iptable6, fwdChainName), []string{"-P FORWARD ACCEPT"})) if tc.insert { _, err = iptable4.Raw("-A", fwdChainName, "-j", "DROP") @@ -74,11 +75,11 @@ func TestUserChain(t *testing.T) { } arrangeUserFilterRule() - assert.DeepEqual(t, getRules(t, iptables.IPv4, fwdChainName), tc.fwdChain) - assert.DeepEqual(t, getRules(t, iptables.IPv6, fwdChainName), tc.fwdChain) + assert.Check(t, is.DeepEqual(getRules(t, iptable4, fwdChainName), tc.fwdChain)) + assert.Check(t, is.DeepEqual(getRules(t, iptable6, fwdChainName), tc.fwdChain)) if tc.userChain != nil { - assert.DeepEqual(t, getRules(t, iptables.IPv4, usrChainName), tc.userChain) - assert.DeepEqual(t, getRules(t, iptables.IPv6, usrChainName), tc.userChain) + assert.Check(t, is.DeepEqual(getRules(t, iptable4, usrChainName), tc.userChain)) + assert.Check(t, is.DeepEqual(getRules(t, iptable6, usrChainName), tc.userChain)) } else { _, err := iptable4.Raw("-S", usrChainName) assert.Assert(t, err != nil, "ipv4 chain %v: created unexpectedly", usrChainName) @@ -89,9 +90,7 @@ func TestUserChain(t *testing.T) { } } -func getRules(t *testing.T, ipVer iptables.IPVersion, chain string) []string { - iptable := iptables.GetIptable(ipVer) - +func getRules(t *testing.T, iptable *iptables.IPTable, chain string) []string { t.Helper() output, err := iptable.Raw("-S", chain) assert.NilError(t, err, "chain %s: failed to get rules", chain)