@@ -998,6 +998,40 @@ var _ = Describe("CreateOrUpdateArgoCD", func() {
998998 Expect (argoCD .GetResourceVersion ()).To (Equal ("1" )) // Ensure it has been updated
999999 })
10001000 })
1001+
1002+ Context ("when there is an error in the getArgoCD fn but there is an argocd" , func () {
1003+
1004+ BeforeEach (func () {
1005+ argoCD := & unstructured.Unstructured {
1006+ Object : map [string ]any {
1007+ "apiVersion" : "argoproj.io/v1beta1" ,
1008+ "kind" : "ArgoCD" ,
1009+ "metadata" : map [string ]any {
1010+ "name" : name ,
1011+ "namespace" : namespace ,
1012+ "resourceVersion" : "1" ,
1013+ },
1014+ },
1015+ }
1016+ _ , err := dynamicClient .Resource (gvr ).Namespace (namespace ).Create (context .TODO (), argoCD , metav1.CreateOptions {})
1017+ Expect (err ).ToNot (HaveOccurred ())
1018+ getArgoCDFunc = func (_ dynamic.Interface , _ , _ string ) (* argooperator.ArgoCD , error ) {
1019+ return nil , fmt .Errorf ("forced error" )
1020+ }
1021+ })
1022+
1023+ It ("should propagate the error and not update the existing argocd" , func () {
1024+ err := createOrUpdateArgoCD (dynamicClient , nil , name , namespace )
1025+ Expect (err ).To (HaveOccurred ())
1026+
1027+ argoCD , err := dynamicClient .Resource (gvr ).Namespace (namespace ).Get (context .TODO (), name , metav1.GetOptions {})
1028+
1029+ Expect (err ).NotTo (HaveOccurred ())
1030+ Expect (argoCD ).ToNot (BeNil ())
1031+ Expect (argoCD .GetResourceVersion ()).To (Equal ("1" ))
1032+
1033+ })
1034+ })
10011035})
10021036
10031037var _ = Describe ("CompareApplication" , func () {
0 commit comments