diff --git a/pkg/controller/compliancescan/compliancescan_controller_test.go b/pkg/controller/compliancescan/compliancescan_controller_test.go index d22dd88cb..2a80d959e 100644 --- a/pkg/controller/compliancescan/compliancescan_controller_test.go +++ b/pkg/controller/compliancescan/compliancescan_controller_test.go @@ -410,9 +410,11 @@ var _ = Describe("Testing compliancescan controller phases", func() { // Set state to DONE compliancescaninstance.Status.Phase = compv1alpha1.PhaseDone - compliancescaninstance.Spec.Debug = true err := reconciler.Client.Status().Update(context.TODO(), compliancescaninstance) Expect(err).To(BeNil()) + compliancescaninstance.Spec.Debug = true + err = reconciler.Client.Update(context.TODO(), compliancescaninstance) + Expect(err).To(BeNil()) }) It("Should return success & not delete the scan pods or secrets (doDelete=false)", func() { result, err := reconciler.phaseDoneHandler(handler, compliancescaninstance, logger, dontDelete) diff --git a/pkg/controller/compliancesuite/compliancesuite_controller_test.go b/pkg/controller/compliancesuite/compliancesuite_controller_test.go index 601e8f66a..435cb151f 100644 --- a/pkg/controller/compliancesuite/compliancesuite_controller_test.go +++ b/pkg/controller/compliancesuite/compliancesuite_controller_test.go @@ -3,6 +3,7 @@ package compliancesuite import ( "context" "encoding/json" + "github.com/ComplianceAsCode/compliance-operator/pkg/controller/metrics" "github.com/ComplianceAsCode/compliance-operator/pkg/controller/metrics/metricsfakes" @@ -207,7 +208,7 @@ var _ = Describe("ComplianceSuiteController", func() { By("The remediation controller setting the applied status") rem.Status.ApplicationState = compv1alpha1.RemediationApplied - err := reconciler.Client.Update(ctx, rem) + err := reconciler.Client.Status().Update(ctx, rem) Expect(err).To(BeNil()) By("Running a second reconcile loop") @@ -222,7 +223,7 @@ var _ = Describe("ComplianceSuiteController", func() { Context("With spec.AutoApplyRemediations = true", func() { BeforeEach(func() { suite.Spec.AutoApplyRemediations = true - err := reconciler.Client.Status().Update(ctx, suite) + err := reconciler.Client.Update(ctx, suite) Expect(err).To(BeNil()) }) Context("With ComplianceSuite and Scans not done", func() { @@ -351,7 +352,7 @@ var _ = Describe("ComplianceSuiteController", func() { By("The remediation controller setting the applied status") rem.Status.ApplicationState = compv1alpha1.RemediationApplied - err := reconciler.Client.Update(ctx, rem) + err := reconciler.Client.Status().Update(ctx, rem) Expect(err).To(BeNil()) By("the pool should be paused") @@ -374,7 +375,7 @@ var _ = Describe("ComplianceSuiteController", func() { Context("With spec.AutoApplyRemediations = true", func() { BeforeEach(func() { suite.Spec.AutoApplyRemediations = true - err := reconciler.Client.Status().Update(ctx, suite) + err := reconciler.Client.Update(ctx, suite) Expect(err).To(BeNil()) }) Context("With ComplianceSuite and Scans not done", func() { @@ -596,7 +597,7 @@ var _ = Describe("ComplianceSuiteController", func() { By("The remediation controller setting the applied status") rem.Status.ApplicationState = compv1alpha1.RemediationApplied - err := reconciler.Client.Update(ctx, rem) + err := reconciler.Client.Status().Update(ctx, rem) Expect(err).To(BeNil()) By("the pool should be paused") @@ -651,7 +652,7 @@ var _ = Describe("ComplianceSuiteController", func() { Context("With spec.AutoApplyRemediations = true", func() { BeforeEach(func() { suite.Spec.AutoApplyRemediations = true - err := reconciler.Client.Status().Update(ctx, suite) + err := reconciler.Client.Update(ctx, suite) Expect(err).To(BeNil()) }) Context("With ComplianceSuite and Scans not done", func() { @@ -875,7 +876,7 @@ var _ = Describe("ComplianceSuiteController", func() { By("The remediation controller setting the applied status") rem.Status.ApplicationState = compv1alpha1.RemediationApplied - err := reconciler.Client.Update(ctx, rem) + err := reconciler.Client.Status().Update(ctx, rem) Expect(err).To(BeNil()) By("the pool should be paused") @@ -930,7 +931,7 @@ var _ = Describe("ComplianceSuiteController", func() { Context("With spec.AutoApplyRemediations = true", func() { BeforeEach(func() { suite.Spec.AutoApplyRemediations = true - err := reconciler.Client.Status().Update(ctx, suite) + err := reconciler.Client.Update(ctx, suite) Expect(err).To(BeNil()) }) Context("With ComplianceSuite and Scans not done", func() { diff --git a/pkg/controller/scansettingbinding/scansettingbinding_controller_test.go b/pkg/controller/scansettingbinding/scansettingbinding_controller_test.go index 8b3fac1a5..cab921ee7 100644 --- a/pkg/controller/scansettingbinding/scansettingbinding_controller_test.go +++ b/pkg/controller/scansettingbinding/scansettingbinding_controller_test.go @@ -3,9 +3,10 @@ package scansettingbinding import ( "context" "regexp" - runtimeclient "sigs.k8s.io/controller-runtime/pkg/client" "strings" + runtimeclient "sigs.k8s.io/controller-runtime/pkg/client" + "github.com/go-logr/zapr" . "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/extensions/table" @@ -35,7 +36,6 @@ var _ = Describe("Testing scansettingbinding controller", func() { profOcpCis *compv1alpha1.Profile tpRhcosE8 *compv1alpha1.TailoredProfile tpOcpCis *compv1alpha1.TailoredProfile - scratchTP *compv1alpha1.TailoredProfile setting *compv1alpha1.ScanSetting ssb *compv1alpha1.ScanSettingBinding @@ -45,6 +45,12 @@ var _ = Describe("Testing scansettingbinding controller", func() { suite *compv1alpha1.ComplianceSuite ) + scratchTP := &compv1alpha1.TailoredProfile{ + TypeMeta: v1.TypeMeta{ + Kind: "TailoredProfile", + APIVersion: compv1alpha1.SchemeGroupVersion.String(), + }, + } BeforeEach(func() { // Uncomment these lines if you need to debug the controller's output. @@ -187,6 +193,10 @@ var _ = Describe("Testing scansettingbinding controller", func() { } scratchTP = &compv1alpha1.TailoredProfile{ + TypeMeta: v1.TypeMeta{ + Kind: "TailoredProfile", + APIVersion: compv1alpha1.SchemeGroupVersion.String(), + }, ObjectMeta: v1.ObjectMeta{ Name: "scratch-tp", Namespace: common.GetComplianceOperatorNamespace(), @@ -698,6 +708,10 @@ var _ = Describe("Testing scansettingbinding controller", func() { Expect(updateErr).To(BeNil()) ssb = &compv1alpha1.ScanSettingBinding{ + TypeMeta: v1.TypeMeta{ + Kind: "ScanSettingBinding", + APIVersion: compv1alpha1.SchemeGroupVersion.String(), + }, ObjectMeta: v1.ObjectMeta{ Name: "tp-not-ready", Namespace: common.GetComplianceOperatorNamespace(), @@ -749,6 +763,10 @@ var _ = Describe("Testing scansettingbinding controller", func() { Expect(updateErr).To(BeNil()) ssb = &compv1alpha1.ScanSettingBinding{ + TypeMeta: v1.TypeMeta{ + Kind: "ScanSettingBinding", + APIVersion: compv1alpha1.SchemeGroupVersion.String(), + }, ObjectMeta: v1.ObjectMeta{ Name: "tp-errored", Namespace: common.GetComplianceOperatorNamespace(),