diff options
author | Ed Santiago <santiago@redhat.com> | 2022-04-27 14:58:46 -0600 |
---|---|---|
committer | Ed Santiago <santiago@redhat.com> | 2022-04-28 05:41:53 -0600 |
commit | b3f38c31b29b51440edd5913a90019efbced0862 (patch) | |
tree | 72749f8e3ddedee0bb882c186a7f3cee08fe5f1c /test/e2e/network_test.go | |
parent | 2b8cafc0671fbbd155770f044b8216f050877192 (diff) | |
download | podman-b3f38c31b29b51440edd5913a90019efbced0862.tar.gz podman-b3f38c31b29b51440edd5913a90019efbced0862.tar.bz2 podman-b3f38c31b29b51440edd5913a90019efbced0862.zip |
Ginkgo: use HaveField() for better error checking
This is a very late followup to my ginkgo-improving work of 2021.
It has been stuck since December because it requires gomega 1.17,
which we've just enabled.
This commit is simply a copy-paste of a command I saved in
my TODO list many months ago:
sed -i -e 's/Expect(\([^ ]\+\)\.\([a-zA-Z0-9]\+\))\.To(Equal(/Expect(\1).To(HaveField(\"\2\", /' test/e2e/*_test.go
Signed-off-by: Ed Santiago <santiago@redhat.com>
Diffstat (limited to 'test/e2e/network_test.go')
-rw-r--r-- | test/e2e/network_test.go | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/test/e2e/network_test.go b/test/e2e/network_test.go index 89a9005f5..c67a4baed 100644 --- a/test/e2e/network_test.go +++ b/test/e2e/network_test.go @@ -293,8 +293,8 @@ var _ = Describe("Podman network", func() { Expect(conData[0].NetworkSettings.Networks).To(HaveLen(1)) net, ok := conData[0].NetworkSettings.Networks[netName] Expect(ok).To(BeTrue()) - Expect(net.NetworkID).To(Equal(netName)) - Expect(net.IPPrefixLen).To(Equal(24)) + Expect(net).To(HaveField("NetworkID", netName)) + Expect(net).To(HaveField("IPPrefixLen", 24)) Expect(net.IPAddress).To(HavePrefix("10.50.50.")) // Necessary to ensure the CNI network is removed cleanly @@ -329,10 +329,10 @@ var _ = Describe("Podman network", func() { Expect(conData[0].NetworkSettings.Networks).To(HaveLen(2)) net1, ok := conData[0].NetworkSettings.Networks[netName1] Expect(ok).To(BeTrue()) - Expect(net1.NetworkID).To(Equal(netName1)) + Expect(net1).To(HaveField("NetworkID", netName1)) net2, ok := conData[0].NetworkSettings.Networks[netName2] Expect(ok).To(BeTrue()) - Expect(net2.NetworkID).To(Equal(netName2)) + Expect(net2).To(HaveField("NetworkID", netName2)) // Necessary to ensure the CNI network is removed cleanly rmAll := podmanTest.Podman([]string{"rm", "-t", "0", "-f", ctrName}) @@ -366,13 +366,13 @@ var _ = Describe("Podman network", func() { Expect(conData[0].NetworkSettings.Networks).To(HaveLen(2)) net1, ok := conData[0].NetworkSettings.Networks[netName1] Expect(ok).To(BeTrue()) - Expect(net1.NetworkID).To(Equal(netName1)) - Expect(net1.IPPrefixLen).To(Equal(25)) + Expect(net1).To(HaveField("NetworkID", netName1)) + Expect(net1).To(HaveField("IPPrefixLen", 25)) Expect(net1.IPAddress).To(HavePrefix("10.50.51.")) net2, ok := conData[0].NetworkSettings.Networks[netName2] Expect(ok).To(BeTrue()) - Expect(net2.NetworkID).To(Equal(netName2)) - Expect(net2.IPPrefixLen).To(Equal(26)) + Expect(net2).To(HaveField("NetworkID", netName2)) + Expect(net2).To(HaveField("IPPrefixLen", 26)) Expect(net2.IPAddress).To(HavePrefix("10.50.51.")) // Necessary to ensure the CNI network is removed cleanly @@ -601,7 +601,7 @@ var _ = Describe("Podman network", func() { Expect(err).To(BeNil()) Expect(results).To(HaveLen(1)) result := results[0] - Expect(result.NetworkInterface).To(Equal("")) + Expect(result).To(HaveField("NetworkInterface", "")) Expect(result.IPAMOptions).To(HaveKeyWithValue("driver", "dhcp")) nc = podmanTest.Podman([]string{"network", "rm", net}) @@ -628,8 +628,8 @@ var _ = Describe("Podman network", func() { Expect(results).To(HaveLen(1)) result := results[0] - Expect(result.Driver).To(Equal("macvlan")) - Expect(result.NetworkInterface).To(Equal("lo")) + Expect(result).To(HaveField("Driver", "macvlan")) + Expect(result).To(HaveField("NetworkInterface", "lo")) Expect(result.IPAMOptions).To(HaveKeyWithValue("driver", "dhcp")) Expect(result.Subnets).To(HaveLen(0)) @@ -672,8 +672,8 @@ var _ = Describe("Podman network", func() { result := results[0] Expect(result.Options).To(HaveKeyWithValue("mtu", "1500")) - Expect(result.Driver).To(Equal("macvlan")) - Expect(result.NetworkInterface).To(Equal("lo")) + Expect(result).To(HaveField("Driver", "macvlan")) + Expect(result).To(HaveField("NetworkInterface", "lo")) Expect(result.IPAMOptions).To(HaveKeyWithValue("driver", "host-local")) Expect(result.Subnets).To(HaveLen(1)) |