diff --git a/.golangci.yml b/.golangci.yml index 13f87bdeb3..571fe0f246 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -17,7 +17,6 @@ linters: - revive - tagalign # useful hints that should be addressed - - ginkgolinter - nakedret - gosmopolitan # usage of time.Local in pkg/k8s.io - tagliatelle # too many JSON keys cannot be changed due to compat diff --git a/pkg/machine/e2e/inspect_test.go b/pkg/machine/e2e/inspect_test.go index a23d0950b1..308ec8e609 100644 --- a/pkg/machine/e2e/inspect_test.go +++ b/pkg/machine/e2e/inspect_test.go @@ -1,8 +1,6 @@ package e2e_test import ( - "strings" - "github.com/containers/podman/v4/pkg/machine" jsoniter "github.com/json-iterator/go" @@ -67,7 +65,7 @@ var _ = Describe("podman machine stop", func() { var inspectInfo []machine.InspectInfo err = jsoniter.Unmarshal(inspectSession.Bytes(), &inspectInfo) Expect(err).ToNot(HaveOccurred()) - Expect(strings.HasSuffix(inspectInfo[0].ConnectionInfo.PodmanSocket.GetPath(), "podman.sock")) + Expect(inspectInfo[0].ConnectionInfo.PodmanSocket.GetPath()).To(HaveSuffix("podman.sock")) inspect := new(inspectMachine) inspect = inspect.withFormat("{{.Name}}") diff --git a/pkg/machine/e2e/list_test.go b/pkg/machine/e2e/list_test.go index fae5a61cf0..4343fd3556 100644 --- a/pkg/machine/e2e/list_test.go +++ b/pkg/machine/e2e/list_test.go @@ -52,12 +52,12 @@ var _ = Describe("podman machine list", func() { firstList, err := mb.setCmd(list.withQuiet()).run() Expect(err).NotTo(HaveOccurred()) Expect(firstList).Should(Exit(0)) - Expect(firstList.outputToStringSlice()).To(HaveLen(0)) // No header with quiet + Expect(firstList.outputToStringSlice()).To(BeEmpty()) // No header with quiet noheaderSession, err := mb.setCmd(list.withNoHeading()).run() // noheader Expect(err).NotTo(HaveOccurred()) Expect(noheaderSession).Should(Exit(0)) - Expect(noheaderSession.outputToStringSlice()).To(HaveLen(0)) + Expect(noheaderSession.outputToStringSlice()).To(BeEmpty()) i := new(initMachine) session, err := mb.setName(name1).setCmd(i.withImagePath(mb.imagePath)).run() diff --git a/test/e2e/create_test.go b/test/e2e/create_test.go index 0af1e34216..3a9df1956e 100644 --- a/test/e2e/create_test.go +++ b/test/e2e/create_test.go @@ -315,7 +315,7 @@ var _ = Describe("Podman create", func() { It("podman create --authfile with nonexistent authfile", func() { session := podmanTest.Podman([]string{"create", "--authfile", "/tmp/nonexistent", "--name=foo", ALPINE}) session.WaitWithDefaultTimeout() - Expect(session).To(Not(Equal(0))) + Expect(session).ToNot(HaveValue(Equal(0))) }) It("podman create --signature-policy", func() { diff --git a/test/e2e/generate_kube_test.go b/test/e2e/generate_kube_test.go index d18c025ccc..decb547594 100644 --- a/test/e2e/generate_kube_test.go +++ b/test/e2e/generate_kube_test.go @@ -182,7 +182,7 @@ var _ = Describe("Podman kube generate", func() { err := yaml.Unmarshal(kube.Out.Contents(), pod) Expect(err).ToNot(HaveOccurred()) Expect(pod.Spec).To(HaveField("HostNetwork", false)) - Expect(pod.Annotations).To(HaveLen(0)) + Expect(pod.Annotations).To(BeEmpty()) numContainers := 0 for range pod.Spec.Containers { diff --git a/test/e2e/images_test.go b/test/e2e/images_test.go index 23e15defb9..7beca4c3e5 100644 --- a/test/e2e/images_test.go +++ b/test/e2e/images_test.go @@ -192,7 +192,7 @@ WORKDIR /test result := podmanTest.Podman([]string{"images", "-q", "-f", "dangling=true"}) result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0), "dangling image output: %q", result.OutputToString()) - Expect(result.OutputToStringArray()).Should(HaveLen(0), "dangling image output: %q", result.OutputToString()) + Expect(result.OutputToStringArray()).Should(BeEmpty(), "dangling image output: %q", result.OutputToString()) }) It("podman pull by digest and list --all", func() { diff --git a/test/e2e/inspect_test.go b/test/e2e/inspect_test.go index e37765da45..1f00eabc07 100644 --- a/test/e2e/inspect_test.go +++ b/test/e2e/inspect_test.go @@ -571,7 +571,7 @@ var _ = Describe("Podman inspect", func() { session = podmanTest.Podman([]string{"container", "inspect", cid, "-f", "{{ .State.Error }}"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - Expect(session.OutputToString()).To(HaveLen(0)) + Expect(session.OutputToString()).To(BeEmpty()) session = podmanTest.Podman([]string{"start", cid}) session.WaitWithDefaultTimeout() @@ -579,7 +579,7 @@ var _ = Describe("Podman inspect", func() { session = podmanTest.Podman([]string{"container", "inspect", cid, "-f", "'{{ .State.Error }}"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - Expect(session.OutputToString()).To(Not(HaveLen(0))) + Expect(session.OutputToString()).ToNot(BeEmpty()) }) }) diff --git a/test/e2e/network_test.go b/test/e2e/network_test.go index 2f207468ce..6fccf22950 100644 --- a/test/e2e/network_test.go +++ b/test/e2e/network_test.go @@ -569,7 +569,7 @@ var _ = Describe("Podman network", func() { 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)) + Expect(result.Subnets).To(BeEmpty()) nc = podmanTest.Podman([]string{"network", "rm", net}) nc.WaitWithDefaultTimeout() @@ -599,7 +599,7 @@ var _ = Describe("Podman network", func() { Expect(result).To(HaveField("Driver", "ipvlan")) Expect(result).To(HaveField("NetworkInterface", "lo")) Expect(result.IPAMOptions).To(HaveKeyWithValue("driver", "dhcp")) - Expect(result.Subnets).To(HaveLen(0)) + Expect(result.Subnets).To(BeEmpty()) nc = podmanTest.Podman([]string{"network", "rm", net}) nc.WaitWithDefaultTimeout() diff --git a/test/e2e/pause_test.go b/test/e2e/pause_test.go index b02d2c1e25..bcd31f347a 100644 --- a/test/e2e/pause_test.go +++ b/test/e2e/pause_test.go @@ -464,7 +464,7 @@ var _ = Describe("Podman pause", func() { session1 = podmanTest.Podman([]string{"pause", "-a", "--filter", fmt.Sprintf("id=%swrongid", shortCid3)}) session1.WaitWithDefaultTimeout() Expect(session1).Should(Exit(0)) - Expect(session1.OutputToString()).To(HaveLen(0)) + Expect(session1.OutputToString()).To(BeEmpty()) session1 = podmanTest.Podman([]string{"pause", "-a", "--filter", fmt.Sprintf("id=%s", shortCid3)}) session1.WaitWithDefaultTimeout() @@ -474,7 +474,7 @@ var _ = Describe("Podman pause", func() { session1 = podmanTest.Podman([]string{"unpause", "-a", "--filter", fmt.Sprintf("id=%swrongid", shortCid3)}) session1.WaitWithDefaultTimeout() Expect(session1).Should(Exit(0)) - Expect(session1.OutputToString()).To(HaveLen(0)) + Expect(session1.OutputToString()).To(BeEmpty()) session1 = podmanTest.Podman([]string{"unpause", "-a", "--filter", fmt.Sprintf("id=%s", shortCid3)}) session1.WaitWithDefaultTimeout() diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go index 4b9c2f7faa..4da73e9420 100644 --- a/test/e2e/play_kube_test.go +++ b/test/e2e/play_kube_test.go @@ -3665,7 +3665,7 @@ o: {{ .Options.o }}`}) kube := podmanTest.Podman([]string{"play", "kube", kubeYaml}) kube.WaitWithDefaultTimeout() if IsRemote() { - Expect(kube).Error() + Expect(kube).To(ExitWithError()) Expect(kube.ErrorToString()).To(ContainSubstring("importing volumes is not supported for remote requests")) return } @@ -4947,7 +4947,7 @@ spec: ps := podmanTest.Podman([]string{"pod", "ps", "-q"}) ps.WaitWithDefaultTimeout() Expect(ps).Should(Exit(0)) - Expect(ps.OutputToStringArray()).To(HaveLen(0)) + Expect(ps.OutputToStringArray()).To(BeEmpty()) }) It("podman play kube with named volume subpaths", func() { diff --git a/test/e2e/pod_create_test.go b/test/e2e/pod_create_test.go index e725eea1ca..40b4fc4dc5 100644 --- a/test/e2e/pod_create_test.go +++ b/test/e2e/pod_create_test.go @@ -1058,9 +1058,9 @@ ENTRYPOINT ["sleep","99999"] data := inspectPod.InspectPodToJSON() inspect := podmanTest.InspectContainer(ctrCreate.OutputToString()) - Expect(data.CgroupPath).To(HaveLen(0)) + Expect(data.CgroupPath).To(BeEmpty()) if podmanTest.CgroupManager == "cgroupfs" || !isRootless() { - Expect(inspect[0].HostConfig.CgroupParent).To(HaveLen(0)) + Expect(inspect[0].HostConfig.CgroupParent).To(BeEmpty()) } else if podmanTest.CgroupManager == "systemd" { Expect(inspect[0].HostConfig).To(HaveField("CgroupParent", "user.slice")) } diff --git a/test/e2e/prune_test.go b/test/e2e/prune_test.go index 913383fc80..6e7ec4a96c 100644 --- a/test/e2e/prune_test.go +++ b/test/e2e/prune_test.go @@ -261,7 +261,7 @@ var _ = Describe("Podman prune", func() { session = podmanTest.Podman([]string{"network", "ls", "-q", "--filter", "name=^test$"}) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) - Expect(session.OutputToStringArray()).To(HaveLen(0)) + Expect(session.OutputToStringArray()).To(BeEmpty()) // Create new network. session = podmanTest.Podman([]string{"network", "create", "test1", "--label", "foo"}) diff --git a/test/e2e/restart_test.go b/test/e2e/restart_test.go index 7c31f84fb8..3986476705 100644 --- a/test/e2e/restart_test.go +++ b/test/e2e/restart_test.go @@ -324,7 +324,7 @@ var _ = Describe("Podman restart", func() { session1 = podmanTest.Podman([]string{"restart", "-a", "--filter", fmt.Sprintf("id=%swrongid", shortCid3)}) session1.WaitWithDefaultTimeout() Expect(session1).Should(Exit(0)) - Expect(session1.OutputToString()).To(HaveLen(0)) + Expect(session1.OutputToString()).To(BeEmpty()) session1 = podmanTest.Podman([]string{"restart", "-a", "--filter", fmt.Sprintf("id=%s", shortCid3)}) session1.WaitWithDefaultTimeout() diff --git a/test/e2e/rm_test.go b/test/e2e/rm_test.go index 77c669d918..b4b5b17ef9 100644 --- a/test/e2e/rm_test.go +++ b/test/e2e/rm_test.go @@ -305,7 +305,7 @@ var _ = Describe("Podman rm", func() { session1 = podmanTest.Podman([]string{"rm", "-a", "-f", "--filter", fmt.Sprintf("id=%swrongid", shortCid3)}) session1.WaitWithDefaultTimeout() Expect(session1).Should(Exit(0)) - Expect(session1.OutputToString()).To(HaveLen(0)) + Expect(session1.OutputToString()).To(BeEmpty()) session1 = podmanTest.Podman([]string{"rm", "-a", "-f", "--filter", fmt.Sprintf("id=%s", shortCid3)}) session1.WaitWithDefaultTimeout() diff --git a/test/e2e/start_test.go b/test/e2e/start_test.go index 90df80656e..fe1b7ce963 100644 --- a/test/e2e/start_test.go +++ b/test/e2e/start_test.go @@ -145,7 +145,7 @@ var _ = Describe("Podman start", func() { wait.WaitWithDefaultTimeout() Expect(wait).To(ExitWithError()) - Eventually(podmanTest.NumberOfContainers(), defaultWaitTimeout, 3.0).Should(BeZero()) + Eventually(podmanTest.NumberOfContainers, defaultWaitTimeout, 3.0).Should(BeZero()) }) It("podman failed to start without --rm should NOT delete the container", func() { @@ -157,7 +157,7 @@ var _ = Describe("Podman start", func() { start.WaitWithDefaultTimeout() Expect(start).To(ExitWithError()) - Eventually(podmanTest.NumberOfContainers(), defaultWaitTimeout, 3.0).Should(Equal(1)) + Eventually(podmanTest.NumberOfContainers, defaultWaitTimeout, 3.0).Should(Equal(1)) }) It("podman start --sig-proxy should not work without --attach", func() { @@ -216,12 +216,12 @@ var _ = Describe("Podman start", func() { session1 = podmanTest.Podman([]string{"start", cid1, "-f", "status=running"}) session1.WaitWithDefaultTimeout() Expect(session1).Should(Exit(0)) - Expect(session1.OutputToString()).To(HaveLen(0)) + Expect(session1.OutputToString()).To(BeEmpty()) session1 = podmanTest.Podman([]string{"start", "--all", "--filter", fmt.Sprintf("id=%swrongid", shortCid3)}) session1.WaitWithDefaultTimeout() Expect(session1).Should(Exit(0)) - Expect(session1.OutputToString()).To(HaveLen(0)) + Expect(session1.OutputToString()).To(BeEmpty()) session1 = podmanTest.Podman([]string{"start", "--all", "--filter", fmt.Sprintf("id=%s", shortCid3)}) session1.WaitWithDefaultTimeout() diff --git a/test/e2e/stop_test.go b/test/e2e/stop_test.go index c707444072..38e38b9da0 100644 --- a/test/e2e/stop_test.go +++ b/test/e2e/stop_test.go @@ -398,7 +398,7 @@ var _ = Describe("Podman stop", func() { session1 = podmanTest.Podman([]string{"stop", "-a", "--filter", fmt.Sprintf("id=%swrongid", shortCid3)}) session1.WaitWithDefaultTimeout() Expect(session1).Should(Exit(0)) - Expect(session1.OutputToString()).To(HaveLen(0)) + Expect(session1.OutputToString()).To(BeEmpty()) session1 = podmanTest.Podman([]string{"stop", "-a", "--filter", fmt.Sprintf("id=%s", shortCid3)}) session1.WaitWithDefaultTimeout()