From 132e80aeefdd40be6827996ab1d946537a9050c8 Mon Sep 17 00:00:00 2001 From: Danielxlee Date: Thu, 17 Sep 2020 15:24:16 +0800 Subject: [PATCH] Replace 'Expect(err).Should(Succeed())' with 'Expect(err).NotTo(HaveOccurred())' in test --- test/e2e-ansible/e2e_ansible_cluster_test.go | 2 +- test/e2e-ansible/e2e_ansible_olm_test.go | 4 ++-- test/e2e-ansible/e2e_ansible_suite_test.go | 16 ++++++++-------- test/e2e-go/e2e_go_cluster_test.go | 2 +- test/e2e-go/e2e_go_olm_test.go | 4 ++-- test/e2e-go/e2e_go_suite_test.go | 12 ++++++------ test/e2e-helm/e2e_helm_cluster_test.go | 2 +- test/e2e-helm/e2e_helm_olm_test.go | 4 ++-- test/e2e-helm/e2e_helm_suite_test.go | 12 ++++++------ 9 files changed, 29 insertions(+), 29 deletions(-) diff --git a/test/e2e-ansible/e2e_ansible_cluster_test.go b/test/e2e-ansible/e2e_ansible_cluster_test.go index 53caed15a5..9e2ce92274 100644 --- a/test/e2e-ansible/e2e_ansible_cluster_test.go +++ b/test/e2e-ansible/e2e_ansible_cluster_test.go @@ -52,7 +52,7 @@ var _ = Describe("Running ansible projects", func() { By("deploying project on the cluster") err := tc.Make("deploy", "IMG="+tc.ImageName) - Expect(err).Should(Succeed()) + Expect(err).NotTo(HaveOccurred()) }) AfterEach(func() { By("deleting Curl Pod created") diff --git a/test/e2e-ansible/e2e_ansible_olm_test.go b/test/e2e-ansible/e2e_ansible_olm_test.go index c7ba8f0f1a..efe8a6f732 100644 --- a/test/e2e-ansible/e2e_ansible_olm_test.go +++ b/test/e2e-ansible/e2e_ansible_olm_test.go @@ -64,12 +64,12 @@ var _ = Describe("Integrating ansible Projects with OLM", func() { if isRunningOnKind() { By("loading the bundle image into Kind cluster") err = tc.LoadImageToKindClusterWithName(bundleImage) - Expect(err).Should(Succeed()) + Expect(err).NotTo(HaveOccurred()) } By("adding the 'packagemanifests' rule to the Makefile") err = tc.AddPackagemanifestsTarget() - Expect(err).Should(Succeed()) + Expect(err).NotTo(HaveOccurred()) By("generating the operator package manifests") err = tc.Make("packagemanifests", "IMG="+tc.ImageName) diff --git a/test/e2e-ansible/e2e_ansible_suite_test.go b/test/e2e-ansible/e2e_ansible_suite_test.go index 8946630458..88f0156795 100644 --- a/test/e2e-ansible/e2e_ansible_suite_test.go +++ b/test/e2e-ansible/e2e_ansible_suite_test.go @@ -60,7 +60,7 @@ var _ = BeforeSuite(func(done Done) { By("checking the cluster type") kubectx, err = tc.Kubectl.Command("config", "current-context") - Expect(err).Should(Succeed()) + Expect(err).NotTo(HaveOccurred()) By("checking API resources applied on Cluster") output, err := tc.Kubectl.Command("api-resources") @@ -101,7 +101,7 @@ var _ = BeforeSuite(func(done Done) { "--plugins", "ansible", "--project-version", "3-alpha", "--domain", tc.Domain) - Expect(err).Should(Succeed()) + Expect(err).NotTo(HaveOccurred()) By("creating the Memcached API") err = tc.CreateAPI( @@ -110,7 +110,7 @@ var _ = BeforeSuite(func(done Done) { "--kind", tc.Kind, "--generate-playbook", "--generate-role") - Expect(err).Should(Succeed()) + Expect(err).NotTo(HaveOccurred()) By("replacing project Dockerfile to use ansible base image with the dev tag") testutils.ReplaceRegexInFile(filepath.Join(tc.Dir, "Dockerfile"), "quay.io/operator-framework/ansible-operator:.*", "quay.io/operator-framework/ansible-operator:dev") @@ -134,7 +134,7 @@ var _ = BeforeSuite(func(done Done) { "--version", tc.Version, "--kind", "Memfin", "--generate-role") - Expect(err).Should(Succeed()) + Expect(err).NotTo(HaveOccurred()) By("adding task to delete config map") testutils.ReplaceInFile(filepath.Join(tc.Dir, "roles", "memfin", "tasks", "main.yml"), @@ -150,7 +150,7 @@ var _ = BeforeSuite(func(done Done) { "--version", tc.Version, "--kind", "Foo", "--generate-role") - Expect(err).Should(Succeed()) + Expect(err).NotTo(HaveOccurred()) By("adding RBAC permissions for the Memcached Kind") testutils.ReplaceInFile(filepath.Join(tc.Dir, "config", "rbac", "role.yaml"), @@ -158,16 +158,16 @@ var _ = BeforeSuite(func(done Done) { By("checking the kustomize setup") err = tc.Make("kustomize") - Expect(err).Should(Succeed()) + Expect(err).NotTo(HaveOccurred()) By("building the project image") err = tc.Make("docker-build", "IMG="+tc.ImageName) - Expect(err).Should(Succeed()) + Expect(err).NotTo(HaveOccurred()) if isRunningOnKind() { By("loading the project image into Kind cluster") err = tc.LoadImageToKindCluster() - Expect(err).Should(Succeed()) + Expect(err).NotTo(HaveOccurred()) } close(done) diff --git a/test/e2e-go/e2e_go_cluster_test.go b/test/e2e-go/e2e_go_cluster_test.go index 662981cfb2..65c5ccbb79 100644 --- a/test/e2e-go/e2e_go_cluster_test.go +++ b/test/e2e-go/e2e_go_cluster_test.go @@ -40,7 +40,7 @@ var _ = Describe("operator-sdk", func() { By("deploying project on the cluster") err := tc.Make("deploy", "IMG="+tc.ImageName) - Expect(err).Should(Succeed()) + Expect(err).NotTo(HaveOccurred()) }) AfterEach(func() { By("cleaning up the operator and resources") diff --git a/test/e2e-go/e2e_go_olm_test.go b/test/e2e-go/e2e_go_olm_test.go index f3ee4c8e0d..0696f7ed59 100644 --- a/test/e2e-go/e2e_go_olm_test.go +++ b/test/e2e-go/e2e_go_olm_test.go @@ -60,12 +60,12 @@ var _ = Describe("Integrating Go Projects with OLM", func() { if isRunningOnKind() { By("loading the bundle image into Kind cluster") err = tc.LoadImageToKindClusterWithName(bundleImage) - Expect(err).Should(Succeed()) + Expect(err).NotTo(HaveOccurred()) } By("adding the 'packagemanifests' rule to the Makefile") err = tc.AddPackagemanifestsTarget() - Expect(err).Should(Succeed()) + Expect(err).NotTo(HaveOccurred()) By("generating the operator package manifests") err = tc.Make("packagemanifests", "IMG="+tc.ImageName) diff --git a/test/e2e-go/e2e_go_suite_test.go b/test/e2e-go/e2e_go_suite_test.go index 50b208329d..57a858b637 100644 --- a/test/e2e-go/e2e_go_suite_test.go +++ b/test/e2e-go/e2e_go_suite_test.go @@ -62,7 +62,7 @@ var _ = BeforeSuite(func(done Done) { By("checking the cluster type") kubectx, err = tc.Kubectl.Command("config", "current-context") - Expect(err).Should(Succeed()) + Expect(err).NotTo(HaveOccurred()) By("checking API resources applied on Cluster") output, err := tc.Kubectl.Command("api-resources") @@ -99,7 +99,7 @@ var _ = BeforeSuite(func(done Done) { "--repo", path.Join("github.com", "example", projectName), "--domain", tc.Domain, "--fetch-deps=false") - Expect(err).Should(Succeed()) + Expect(err).NotTo(HaveOccurred()) By("by adding scorecard custom patch file") err = tc.AddScorecardCustomPatchFile() @@ -114,7 +114,7 @@ var _ = BeforeSuite(func(done Done) { "--resource", "--controller", "--make=false") - Expect(err).Should(Succeed()) + Expect(err).NotTo(HaveOccurred()) By("implementing the API") Expect(kbtestutils.InsertCode( @@ -132,16 +132,16 @@ var _ = BeforeSuite(func(done Done) { By("checking the kustomize setup") err = tc.Make("kustomize") - Expect(err).Should(Succeed()) + Expect(err).NotTo(HaveOccurred()) By("building the project image") err = tc.Make("docker-build", "IMG="+tc.ImageName) - Expect(err).Should(Succeed()) + Expect(err).NotTo(HaveOccurred()) if isRunningOnKind() { By("loading the project image into Kind cluster") err = tc.LoadImageToKindCluster() - Expect(err).Should(Succeed()) + Expect(err).NotTo(HaveOccurred()) } close(done) diff --git a/test/e2e-helm/e2e_helm_cluster_test.go b/test/e2e-helm/e2e_helm_cluster_test.go index 5fdedb51fc..1f16c1140c 100644 --- a/test/e2e-helm/e2e_helm_cluster_test.go +++ b/test/e2e-helm/e2e_helm_cluster_test.go @@ -40,7 +40,7 @@ var _ = Describe("Running Helm projects", func() { By("deploying project on the cluster") err := tc.Make("deploy", "IMG="+tc.ImageName) - Expect(err).Should(Succeed()) + Expect(err).NotTo(HaveOccurred()) }) AfterEach(func() { By("deleting Curl Pod created") diff --git a/test/e2e-helm/e2e_helm_olm_test.go b/test/e2e-helm/e2e_helm_olm_test.go index 121c7de55e..ad9432f652 100644 --- a/test/e2e-helm/e2e_helm_olm_test.go +++ b/test/e2e-helm/e2e_helm_olm_test.go @@ -64,12 +64,12 @@ var _ = Describe("Integrating Helm Projects with OLM", func() { if isRunningOnKind() { By("loading the bundle image into Kind cluster") err = tc.LoadImageToKindClusterWithName(bundleImage) - Expect(err).Should(Succeed()) + Expect(err).NotTo(HaveOccurred()) } By("adding the 'packagemanifests' rule to the Makefile") err = tc.AddPackagemanifestsTarget() - Expect(err).Should(Succeed()) + Expect(err).NotTo(HaveOccurred()) By("generating the operator package manifests") err = tc.Make("packagemanifests", "IMG="+tc.ImageName) diff --git a/test/e2e-helm/e2e_helm_suite_test.go b/test/e2e-helm/e2e_helm_suite_test.go index 5fe54770be..edcbfbf0a5 100644 --- a/test/e2e-helm/e2e_helm_suite_test.go +++ b/test/e2e-helm/e2e_helm_suite_test.go @@ -59,7 +59,7 @@ var _ = BeforeSuite(func(done Done) { By("checking the cluster type") kubectx, err = tc.Kubectl.Command("config", "current-context") - Expect(err).Should(Succeed()) + Expect(err).NotTo(HaveOccurred()) By("checking API resources applied on Cluster") output, err := tc.Kubectl.Command("api-resources") @@ -94,30 +94,30 @@ var _ = BeforeSuite(func(done Done) { "--plugins", "helm", "--project-version", "3-alpha", "--domain", tc.Domain) - Expect(err).Should(Succeed()) + Expect(err).NotTo(HaveOccurred()) By("creating an API definition") err = tc.CreateAPI( "--group", tc.Group, "--version", tc.Version, "--kind", tc.Kind) - Expect(err).Should(Succeed()) + Expect(err).NotTo(HaveOccurred()) By("replacing project Dockerfile to use Helm base image with the dev tag") testutils.ReplaceRegexInFile(filepath.Join(tc.Dir, "Dockerfile"), "quay.io/operator-framework/helm-operator:.*", "quay.io/operator-framework/helm-operator:dev") By("checking the kustomize setup") err = tc.Make("kustomize") - Expect(err).Should(Succeed()) + Expect(err).NotTo(HaveOccurred()) By("building the project image") err = tc.Make("docker-build", "IMG="+tc.ImageName) - Expect(err).Should(Succeed()) + Expect(err).NotTo(HaveOccurred()) if isRunningOnKind() { By("loading the project image into Kind cluster") err = tc.LoadImageToKindCluster() - Expect(err).Should(Succeed()) + Expect(err).NotTo(HaveOccurred()) } close(done)