Skip to content

Commit

Permalink
test: enforce standards by ginkgo linter
Browse files Browse the repository at this point in the history
  • Loading branch information
osmman committed Jul 31, 2024
1 parent c7cae29 commit e6707cf
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions internal/controller/common/utils/set_trusted_ca_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
},
},
{
Expand Down Expand Up @@ -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)
})
Expand Down
6 changes: 3 additions & 3 deletions internal/controller/ctlog/actions/handle_fulcio_root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))

Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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"))

Expand Down
6 changes: 3 additions & 3 deletions internal/controller/fulcio/utils/fulcio_deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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"))
}

Expand All @@ -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"))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
},
},
},
Expand Down
8 changes: 4 additions & 4 deletions internal/controller/tuf/actions/generate_cert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))

Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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]))

Expand Down Expand Up @@ -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"))

Expand Down
2 changes: 1 addition & 1 deletion internal/controller/tuf/tuf_hot_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit e6707cf

Please sign in to comment.