@@ -79,6 +79,65 @@ func Test_GetImagesFromApplication(t *testing.T) {
79
79
})
80
80
}
81
81
82
+ func Test_GetImagesAndAliasesFromApplication (t * testing.T ) {
83
+ t .Run ("Get list of images from application" , func (t * testing.T ) {
84
+ application := & v1alpha1.Application {
85
+ ObjectMeta : v1.ObjectMeta {
86
+ Name : "test-app" ,
87
+ Namespace : "argocd" ,
88
+ },
89
+ Spec : v1alpha1.ApplicationSpec {},
90
+ Status : v1alpha1.ApplicationStatus {
91
+ Summary : v1alpha1.ApplicationSummary {
92
+ Images : []string {"nginx:1.12.2" , "that/image" , "quay.io/dexidp/dex:v1.23.0" },
93
+ },
94
+ },
95
+ }
96
+ imageList := GetImagesAndAliasesFromApplication (application )
97
+ require .Len (t , imageList , 3 )
98
+ assert .Equal (t , "nginx" , imageList [0 ].ImageName )
99
+ assert .Equal (t , "that/image" , imageList [1 ].ImageName )
100
+ assert .Equal (t , "dexidp/dex" , imageList [2 ].ImageName )
101
+ })
102
+
103
+ t .Run ("Get list of images and image aliases from application that has no images" , func (t * testing.T ) {
104
+ application := & v1alpha1.Application {
105
+ ObjectMeta : v1.ObjectMeta {
106
+ Name : "test-app" ,
107
+ Namespace : "argocd" ,
108
+ },
109
+ Spec : v1alpha1.ApplicationSpec {},
110
+ Status : v1alpha1.ApplicationStatus {
111
+ Summary : v1alpha1.ApplicationSummary {},
112
+ },
113
+ }
114
+ imageList := GetImagesAndAliasesFromApplication (application )
115
+ assert .Empty (t , imageList )
116
+ })
117
+
118
+ t .Run ("Get list of images and aliases from application annotations" , func (t * testing.T ) {
119
+ application := & v1alpha1.Application {
120
+ ObjectMeta : v1.ObjectMeta {
121
+ Name : "test-app" ,
122
+ Namespace : "argocd" ,
123
+ Annotations : map [string ]string {
124
+ common .ImageUpdaterAnnotation : "webserver=nginx" ,
125
+ },
126
+ },
127
+ Spec : v1alpha1.ApplicationSpec {},
128
+ Status : v1alpha1.ApplicationStatus {
129
+ Summary : v1alpha1.ApplicationSummary {
130
+ Images : []string {"nginx:1.12.2" },
131
+ },
132
+ },
133
+ }
134
+ imageList := GetImagesAndAliasesFromApplication (application )
135
+ require .Len (t , imageList , 1 )
136
+ assert .Equal (t , "nginx" , imageList [0 ].ImageName )
137
+ assert .Equal (t , "webserver" , imageList [0 ].ImageAlias )
138
+ })
139
+ }
140
+
82
141
func Test_GetApplicationType (t * testing.T ) {
83
142
t .Run ("Get application of type Helm" , func (t * testing.T ) {
84
143
application := & v1alpha1.Application {
0 commit comments