@@ -81,6 +81,75 @@ func Test_GetImagesFromApplication(t *testing.T) {
8181 assert .Equal (t , "nginx" , imageList [0 ].ImageName )
8282 assert .Nil (t , imageList [0 ].ImageTag )
8383 })
84+
85+ t .Run ("Get list of images from application with force-update and zero replicas - Helm" , func (t * testing.T ) {
86+ application := & v1alpha1.Application {
87+ ObjectMeta : v1.ObjectMeta {
88+ Name : "test-app" ,
89+ Namespace : "argocd" ,
90+ Annotations : map [string ]string {
91+ fmt .Sprintf (registryCommon .Prefixed (common .ImageUpdaterAnnotationPrefix , registryCommon .ForceUpdateOptionAnnotationSuffix ), "myapp" ): "true" ,
92+ common .ImageUpdaterAnnotation : "myapp=myregistry/myapp" ,
93+ },
94+ },
95+ Spec : v1alpha1.ApplicationSpec {
96+ Source : & v1alpha1.ApplicationSource {
97+ Helm : & v1alpha1.ApplicationSourceHelm {
98+ Parameters : []v1alpha1.HelmParameter {
99+ {
100+ Name : "image.tag" ,
101+ Value : "1.2.3" ,
102+ },
103+ },
104+ },
105+ },
106+ },
107+ Status : v1alpha1.ApplicationStatus {
108+ SourceType : v1alpha1 .ApplicationSourceTypeHelm ,
109+ Summary : v1alpha1.ApplicationSummary {
110+ Images : []string {}, // Empty - simulating 0 replicas
111+ },
112+ },
113+ }
114+ imageList := GetImagesFromApplication (application )
115+ require .Len (t , imageList , 1 )
116+ assert .Equal (t , "myregistry/myapp" , imageList [0 ].ImageName )
117+ assert .NotNil (t , imageList [0 ].ImageTag )
118+ assert .Equal (t , "1.2.3" , imageList [0 ].ImageTag .TagName )
119+ })
120+
121+ t .Run ("Get list of images from application with force-update and zero replicas - Kustomize" , func (t * testing.T ) {
122+ application := & v1alpha1.Application {
123+ ObjectMeta : v1.ObjectMeta {
124+ Name : "test-app" ,
125+ Namespace : "argocd" ,
126+ Annotations : map [string ]string {
127+ fmt .Sprintf (registryCommon .Prefixed (common .ImageUpdaterAnnotationPrefix , registryCommon .ForceUpdateOptionAnnotationSuffix ), "myapp" ): "true" ,
128+ common .ImageUpdaterAnnotation : "myapp=myregistry/myapp" ,
129+ },
130+ },
131+ Spec : v1alpha1.ApplicationSpec {
132+ Source : & v1alpha1.ApplicationSource {
133+ Kustomize : & v1alpha1.ApplicationSourceKustomize {
134+ Images : v1alpha1.KustomizeImages {
135+ "myregistry/myapp:2.3.4" ,
136+ },
137+ },
138+ },
139+ },
140+ Status : v1alpha1.ApplicationStatus {
141+ SourceType : v1alpha1 .ApplicationSourceTypeKustomize ,
142+ Summary : v1alpha1.ApplicationSummary {
143+ Images : []string {}, // Empty - simulating 0 replicas
144+ },
145+ },
146+ }
147+ imageList := GetImagesFromApplication (application )
148+ require .Len (t , imageList , 1 )
149+ assert .Equal (t , "myregistry/myapp" , imageList [0 ].ImageName )
150+ assert .NotNil (t , imageList [0 ].ImageTag )
151+ assert .Equal (t , "2.3.4" , imageList [0 ].ImageTag .TagName )
152+ })
84153}
85154
86155func Test_GetImagesAndAliasesFromApplication (t * testing.T ) {
0 commit comments