From 300f77085d07c26fe5be99c2c98a973ffe0bb86f Mon Sep 17 00:00:00 2001 From: prafull01 Date: Fri, 18 Sep 2020 19:29:47 +0530 Subject: [PATCH] Added the ginkgo style checks for e2e tests --- test/e2e-ansible/e2e_ansible_cluster_test.go | 4 +--- test/e2e-ansible/e2e_ansible_olm_test.go | 2 +- test/e2e-go/e2e_go_cluster_test.go | 4 +--- test/e2e-go/e2e_go_olm_test.go | 4 ++-- test/e2e-helm/e2e_helm_cluster_test.go | 4 +--- test/e2e-helm/e2e_helm_olm_test.go | 2 +- 6 files changed, 7 insertions(+), 13 deletions(-) diff --git a/test/e2e-ansible/e2e_ansible_cluster_test.go b/test/e2e-ansible/e2e_ansible_cluster_test.go index 9e2ce92274..dc97af67f4 100644 --- a/test/e2e-ansible/e2e_ansible_cluster_test.go +++ b/test/e2e-ansible/e2e_ansible_cluster_test.go @@ -94,9 +94,7 @@ var _ = Describe("Running ansible projects", func() { By("ensuring the created controller-manager Pod") podNames := kbtestutils.GetNonEmptyLines(podOutput) - if len(podNames) != 1 { - return fmt.Errorf("expect 1 controller pods running, but got %d", len(podNames)) - } + Expect(podNames).To(HaveLen(1)) controllerPodName = podNames[0] Expect(controllerPodName).Should(ContainSubstring("controller-manager")) diff --git a/test/e2e-ansible/e2e_ansible_olm_test.go b/test/e2e-ansible/e2e_ansible_olm_test.go index efe8a6f732..3678d21b6d 100644 --- a/test/e2e-ansible/e2e_ansible_olm_test.go +++ b/test/e2e-ansible/e2e_ansible_olm_test.go @@ -85,7 +85,7 @@ var _ = Describe("Integrating ansible Projects with OLM", func() { Expect(err).NotTo(HaveOccurred()) err = json.Unmarshal(scorecardOutputBytes, &scorecardOutput) Expect(err).NotTo(HaveOccurred()) - Expect(len(scorecardOutput.Items)).To(Equal(1)) + Expect(scorecardOutput.Items).To(HaveLen(1)) Expect(scorecardOutput.Items[0].Status.Results[0].State).To(Equal(v1alpha3.PassState)) By("running the package") diff --git a/test/e2e-go/e2e_go_cluster_test.go b/test/e2e-go/e2e_go_cluster_test.go index 65c5ccbb79..53b445d7d2 100644 --- a/test/e2e-go/e2e_go_cluster_test.go +++ b/test/e2e-go/e2e_go_cluster_test.go @@ -83,9 +83,7 @@ var _ = Describe("operator-sdk", func() { By("ensuring the created controller-manager Pod") podNames := kbtestutils.GetNonEmptyLines(podOutput) - if len(podNames) != 1 { - return fmt.Errorf("expect 1 controller pods running, but got %d", len(podNames)) - } + Expect(podNames).To(HaveLen(1)) controllerPodName = podNames[0] Expect(controllerPodName).Should(ContainSubstring("controller-manager")) diff --git a/test/e2e-go/e2e_go_olm_test.go b/test/e2e-go/e2e_go_olm_test.go index 0696f7ed59..5e63bd6400 100644 --- a/test/e2e-go/e2e_go_olm_test.go +++ b/test/e2e-go/e2e_go_olm_test.go @@ -90,7 +90,7 @@ var _ = Describe("Integrating Go Projects with OLM", func() { Expect(err).NotTo(HaveOccurred()) err = json.Unmarshal(scorecardOutputBytes, &scorecardOutput) Expect(err).NotTo(HaveOccurred()) - Expect(len(scorecardOutput.Items)).To(Equal(1)) + Expect(scorecardOutput.Items).To(HaveLen(1)) Expect(scorecardOutput.Items[0].Status.Results[0].State).To(Equal(v1alpha3.PassState)) By("running custom scorecard tests") @@ -102,7 +102,7 @@ var _ = Describe("Integrating Go Projects with OLM", func() { Expect(err).NotTo(HaveOccurred()) err = json.Unmarshal(scorecardOutputBytes, &scorecardOutput) Expect(err).NotTo(HaveOccurred()) - Expect(len(scorecardOutput.Items)).To(Equal(2)) + Expect(scorecardOutput.Items).To(HaveLen(2)) By("running olm scorecard tests") runOLMScorecardCmd := exec.Command(tc.BinaryName, "scorecard", "bundle", diff --git a/test/e2e-helm/e2e_helm_cluster_test.go b/test/e2e-helm/e2e_helm_cluster_test.go index 1f16c1140c..59c2f387dd 100644 --- a/test/e2e-helm/e2e_helm_cluster_test.go +++ b/test/e2e-helm/e2e_helm_cluster_test.go @@ -82,9 +82,7 @@ var _ = Describe("Running Helm projects", func() { By("ensuring the created controller-manager Pod") podNames := kbtestutils.GetNonEmptyLines(podOutput) - if len(podNames) != 1 { - return fmt.Errorf("expect 1 controller pods running, but got %d", len(podNames)) - } + Expect(podNames).To(HaveLen(1)) controllerPodName = podNames[0] Expect(controllerPodName).Should(ContainSubstring("controller-manager")) diff --git a/test/e2e-helm/e2e_helm_olm_test.go b/test/e2e-helm/e2e_helm_olm_test.go index ad9432f652..a7c9cc44a3 100644 --- a/test/e2e-helm/e2e_helm_olm_test.go +++ b/test/e2e-helm/e2e_helm_olm_test.go @@ -85,7 +85,7 @@ var _ = Describe("Integrating Helm Projects with OLM", func() { Expect(err).NotTo(HaveOccurred()) err = json.Unmarshal(scorecardOutputBytes, &scorecardOutput) Expect(err).NotTo(HaveOccurred()) - Expect(len(scorecardOutput.Items)).To(Equal(1)) + Expect(scorecardOutput.Items).To(HaveLen(1)) Expect(scorecardOutput.Items[0].Status.Results[0].State).To(Equal(v1alpha3.PassState)) By("running the package")