@@ -36,10 +36,13 @@ import (
3636 . "github.com/onsi/gomega"
3737 "github.com/otiai10/copy"
3838 corev1 "k8s.io/api/core/v1"
39+ apimeta "k8s.io/apimachinery/pkg/api/meta"
3940 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
4041 "k8s.io/apimachinery/pkg/types"
42+ "sigs.k8s.io/controller-runtime/pkg/client"
4143
4244 imagev1_reflect "github.com/fluxcd/image-reflector-controller/api/v1alpha1"
45+ "github.com/fluxcd/pkg/apis/meta"
4346 "github.com/fluxcd/pkg/gittestserver"
4447 sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
4548
@@ -273,6 +276,22 @@ var _ = Describe("ImageUpdateAutomation", func() {
273276 Expect (err ).ToNot (HaveOccurred ())
274277 test .ExpectMatchingDirectories (tmp , expected )
275278 })
279+
280+ It ("stops updating when suspended" , func () {
281+ // suspend it, and check that it is marked as unready.
282+ var updatePatch imagev1.ImageUpdateAutomation
283+ updatePatch .Name = updateKey .Name
284+ updatePatch .Namespace = updateKey .Namespace
285+ updatePatch .Spec .Suspend = true
286+ Expect (k8sClient .Patch (context .Background (), & updatePatch , client .Merge )).To (Succeed ())
287+ Eventually (func () bool {
288+ if err := k8sClient .Get (context .Background (), updateKey , updateBySetters ); err != nil {
289+ return false
290+ }
291+ ready := apimeta .FindStatusCondition (updateBySetters .Status .Conditions , meta .ReadyCondition )
292+ return ready != nil && ready .Status == metav1 .ConditionFalse && ready .Reason == meta .SuspendedReason
293+ }, timeout , time .Second ).Should (BeTrue ())
294+ })
276295 })
277296 })
278297})
0 commit comments