diff --git a/internal/controller/common/utils/set_trusted_ca_test.go b/internal/controller/common/utils/set_trusted_ca_test.go index dba5cbbba..7467ab9b4 100644 --- a/internal/controller/common/utils/set_trusted_ca_test.go +++ b/internal/controller/common/utils/set_trusted_ca_test.go @@ -111,7 +111,7 @@ func TestSetTrustedCA(t *testing.T) { g.Expect(spec.Spec.Volumes).Should(ContainElement(gstruct.MatchFields(gstruct.IgnoreExtras, gstruct.Fields{ "Name": Equal("ca-trust"), }))) - g.Expect(spec.Spec.Volumes[1].VolumeSource.Projected.Sources).Should(HaveLen(0)) + g.Expect(spec.Spec.Volumes[1].VolumeSource.Projected.Sources).Should(BeEmpty()) }, }, { @@ -188,9 +188,9 @@ func TestSetTrustedCA(t *testing.T) { t.Run(tt.name, func(t *testing.T) { err := SetTrustedCA(tt.args.dep, tt.args.lor) if tt.error { - g.Expect(err).ShouldNot(BeNil()) + g.Expect(err).Should(HaveOccurred()) } else { - g.Expect(err).Should(BeNil()) + g.Expect(err).ShouldNot(HaveOccurred()) } tt.want(tt.args.dep, err) }) diff --git a/internal/controller/ctlog/actions/handle_fulcio_root_test.go b/internal/controller/ctlog/actions/handle_fulcio_root_test.go index bd620fde9..02fef5bd8 100644 --- a/internal/controller/ctlog/actions/handle_fulcio_root_test.go +++ b/internal/controller/ctlog/actions/handle_fulcio_root_test.go @@ -53,7 +53,7 @@ func Test_HandleFulcioCert_Autodiscover(t *testing.T) { _ = a.Handle(context.TODO(), i) - g.Expect(len(i.Status.RootCertificates)).Should(Equal(1)) + g.Expect(i.Status.RootCertificates).Should(HaveLen(1)) g.Expect(i.Status.RootCertificates[0].Key).Should(Equal("key")) g.Expect(i.Status.RootCertificates[0].Name).Should(Equal("secret")) @@ -143,7 +143,7 @@ func Test_HandleFulcioCert_Configured(t *testing.T) { g.Expect(a.CanHandle(context.TODO(), i)).To(BeTrue()) _ = a.Handle(context.TODO(), i) - g.Expect(len(i.Status.RootCertificates)).Should(Equal(2)) + g.Expect(i.Status.RootCertificates).Should(HaveLen(2)) g.Expect(i.Status.RootCertificates[0].Key).Should(Equal("key")) g.Expect(i.Status.RootCertificates[0].Name).Should(Equal("secret")) g.Expect(i.Status.RootCertificates[1].Key).Should(Equal("key")) @@ -196,7 +196,7 @@ func Test_HandleFulcioCert_Configured_Priority(t *testing.T) { g.Expect(a.CanHandle(context.TODO(), i)).To(BeTrue()) _ = a.Handle(context.TODO(), i) - g.Expect(len(i.Status.RootCertificates)).Should(Equal(1)) + g.Expect(i.Status.RootCertificates).Should(HaveLen(1)) g.Expect(i.Status.RootCertificates[0].Key).Should(Equal("key")) g.Expect(i.Status.RootCertificates[0].Name).Should(Equal("my-secret")) diff --git a/internal/controller/fulcio/utils/fulcio_deployment_test.go b/internal/controller/fulcio/utils/fulcio_deployment_test.go index daab03403..97f6f76d3 100644 --- a/internal/controller/fulcio/utils/fulcio_deployment_test.go +++ b/internal/controller/fulcio/utils/fulcio_deployment_test.go @@ -40,7 +40,7 @@ func TestSimpleDeploymen(t *testing.T) { // oidc-info volume oidcVolume := findVolume("ca-trust", deployment.Spec.Template.Spec.Volumes) g.Expect(oidcVolume).ShouldNot(BeNil()) - g.Expect(len(oidcVolume.VolumeSource.Projected.Sources)).Should(Equal(0)) + g.Expect(oidcVolume.VolumeSource.Projected.Sources).Should(BeEmpty()) } func TestPrivateKeyPassword(t *testing.T) { @@ -82,7 +82,7 @@ func TestTrustedCA(t *testing.T) { oidcVolume := findVolume("ca-trust", deployment.Spec.Template.Spec.Volumes) g.Expect(oidcVolume).ShouldNot(BeNil()) - g.Expect(len(oidcVolume.VolumeSource.Projected.Sources)).Should(Equal(1)) + g.Expect(oidcVolume.VolumeSource.Projected.Sources).Should(HaveLen(1)) g.Expect(oidcVolume.VolumeSource.Projected.Sources[0].ConfigMap.Name).Should(Equal("trusted")) } @@ -103,7 +103,7 @@ func TestTrustedCAByAnnotation(t *testing.T) { oidcVolume := findVolume("ca-trust", deployment.Spec.Template.Spec.Volumes) g.Expect(oidcVolume).ShouldNot(BeNil()) - g.Expect(len(oidcVolume.VolumeSource.Projected.Sources)).Should(Equal(1)) + g.Expect(oidcVolume.VolumeSource.Projected.Sources).Should(HaveLen(1)) g.Expect(oidcVolume.VolumeSource.Projected.Sources[0].ConfigMap.Name).Should(Equal("trusted-annotation")) } diff --git a/internal/controller/rekor/actions/server/resolve_pub_key_test.go b/internal/controller/rekor/actions/server/resolve_pub_key_test.go index e48dbad0f..6e43aa649 100644 --- a/internal/controller/rekor/actions/server/resolve_pub_key_test.go +++ b/internal/controller/rekor/actions/server/resolve_pub_key_test.go @@ -198,7 +198,7 @@ func TestResolvePubKey_Handle(t *testing.T) { if tt.want.publicKey == nil { secrets := v1.SecretList{} g.Expect(kubernetes.FindByLabelSelector(ctx, c, &secrets, instance.Namespace, RekorPubLabel)).To(Succeed()) - g.Expect(secrets.Items).Should(HaveLen(0)) + g.Expect(secrets.Items).Should(BeEmpty()) } else { secrets := v1.SecretList{} g.Expect(kubernetes.FindByLabelSelector(ctx, c, &secrets, instance.Namespace, RekorPubLabel)).To(Succeed()) diff --git a/internal/controller/rekor/actions/server/sharding_config_test.go b/internal/controller/rekor/actions/server/sharding_config_test.go index 75a49de32..758d2aef5 100644 --- a/internal/controller/rekor/actions/server/sharding_config_test.go +++ b/internal/controller/rekor/actions/server/sharding_config_test.go @@ -280,7 +280,7 @@ func TestShardingConfig_Handle(t *testing.T) { rlr := make([]rhtasv1alpha1.RekorLogRange, 0) g.Expect(yaml.Unmarshal([]byte(cm.Data[shardingConfigName]), &rlr)).To(Succeed()) - g.Expect(rlr).Should(HaveLen(0)) + g.Expect(rlr).Should(BeEmpty()) }, }, }, diff --git a/internal/controller/tuf/actions/generate_cert_test.go b/internal/controller/tuf/actions/generate_cert_test.go index 7967c9727..1d6d72470 100644 --- a/internal/controller/tuf/actions/generate_cert_test.go +++ b/internal/controller/tuf/actions/generate_cert_test.go @@ -45,7 +45,7 @@ func TestKeyAutogenerate(t *testing.T) { }}} testAction.Handle(testContext, instance) - g.Expect(len(instance.Status.Keys)).To(Equal(1)) + g.Expect(instance.Status.Keys).To(HaveLen(1)) g.Expect(instance.Status.Keys[0].SecretRef.Name).To(Equal("testSecret")) g.Expect(instance.Status.Keys[0].SecretRef.Key).To(Equal("key")) @@ -73,7 +73,7 @@ func TestKeyProvided(t *testing.T) { }}}} testAction.Handle(testContext, instance) - g.Expect(len(instance.Status.Keys)).To(Equal(1)) + g.Expect(instance.Status.Keys).To(HaveLen(1)) g.Expect(instance.Status.Keys[0]).To(Equal(instance.Spec.Keys[0])) g.Expect(meta.IsStatusConditionTrue(instance.Status.Conditions, "rekor.pub")).To(BeTrue()) @@ -113,7 +113,7 @@ func TestKeyUpdate(t *testing.T) { testAction.Handle(testContext, instance) - g.Expect(len(instance.Status.Keys)).To(Equal(1)) + g.Expect(instance.Status.Keys).To(HaveLen(1)) g.Expect(instance.Status.Keys[0].SecretRef.Name).To(Equal("new")) g.Expect(instance.Status.Keys[0]).To(Equal(instance.Spec.Keys[0])) @@ -152,7 +152,7 @@ func TestKeyDelete(t *testing.T) { testAction.Handle(testContext, instance) - g.Expect(len(instance.Status.Keys)).To(Equal(1)) + g.Expect(instance.Status.Keys).To(HaveLen(1)) g.Expect(instance.Status.Keys[0].SecretRef).To(Not(BeNil())) g.Expect(instance.Status.Keys[0].SecretRef.Name).To(Equal("new")) diff --git a/internal/controller/tuf/tuf_hot_update_test.go b/internal/controller/tuf/tuf_hot_update_test.go index e35a392e4..e1221b18b 100644 --- a/internal/controller/tuf/tuf_hot_update_test.go +++ b/internal/controller/tuf/tuf_hot_update_test.go @@ -191,7 +191,7 @@ var _ = Describe("TUF update test", func() { }).Should(Succeed()) By("Recreate ctlog secret") - Expect(k8sClient.DeleteAllOf(ctx, &corev1.Secret{}, runtimeCli.InNamespace(TufNamespace), runtimeCli.MatchingLabels(secretLabels))) + Expect(k8sClient.DeleteAllOf(ctx, &corev1.Secret{}, runtimeCli.InNamespace(TufNamespace), runtimeCli.MatchingLabels(secretLabels))).To(Succeed()) By("Pending phase until ctlog public key is resolved") Eventually(func(g Gomega) string {