@@ -102,7 +102,62 @@ func TestApplyFilterAndGetFilteredList(t *testing.T) {
102
102
assert .Equal (t , common .RepoName1 , artifactsNotFound [0 ].Repository )
103
103
assert .Equal (t , common .TagName1 , artifactsNotFound [0 ].Tag )
104
104
})
105
- // 5. Success scenario with all the combination of filters when tag-convention is floating
105
+ // 5. If same repository is specified multiple times with the same tags, it should be returned only once in the filtered list
106
+ t .Run ("SameRepositorySpecifiedMultipleTimesWithSameTagsTest" , func (t * testing.T ) {
107
+ filter := Filter {
108
+ Version : "v1" ,
109
+ Repositories : []Repository {
110
+ {
111
+ Repository : common .RepoName1 ,
112
+ Tags : []string {common .TagName },
113
+ Enabled : boolPtr (true ),
114
+ },
115
+ {
116
+ Repository : common .RepoName1 ,
117
+ Tags : []string {common .TagName },
118
+ Enabled : boolPtr (true ),
119
+ },
120
+ },
121
+ }
122
+ mockAcrClient .On ("GetAcrTags" , common .TestCtx , common .RepoName1 , "" , "" ).Return (common .OneTagResult , nil ).Twice ()
123
+ mockAcrClient .On ("GetAcrTags" , common .TestCtx , common .RepoName1 , "" , common .TagName ).Return (common .EmptyListTagsResult , nil ).Twice ()
124
+ filteredRepositories , artifactsNotFound , err := ApplyFilterAndGetFilteredList (context .Background (), mockAcrClient , filter )
125
+ assert .NoError (t , err )
126
+ assert .Len (t , filteredRepositories , 1 )
127
+ assert .Equal (t , common .RepoName1 , filteredRepositories [0 ].Repository )
128
+ assert .Equal (t , common .TagName , filteredRepositories [0 ].Tag )
129
+ assert .Equal (t , "N/A" , filteredRepositories [0 ].PatchTag )
130
+ assert .Nil (t , artifactsNotFound )
131
+ assert .Len (t , artifactsNotFound , 0 )
132
+ })
133
+ // 6. If same repository is specified multiple times with same and different tags, filtered list should contain all unique tags
134
+ t .Run ("SameRepositorySpecifiedMultipleTimesWithDifferentTagsTest" , func (t * testing.T ) {
135
+ filter := Filter {
136
+ Version : "v1" ,
137
+ Repositories : []Repository {
138
+ {
139
+ Repository : common .RepoName1 ,
140
+ Tags : []string {common .TagName1 },
141
+ Enabled : boolPtr (true ),
142
+ },
143
+ {
144
+ Repository : common .RepoName1 ,
145
+ Tags : []string {common .TagName1 , common .TagName2 },
146
+ Enabled : boolPtr (true ),
147
+ },
148
+ },
149
+ }
150
+ mockAcrClient .On ("GetAcrTags" , common .TestCtx , common .RepoName1 , "" , "" ).Return (common .FourTagsResultWithPatchTags , nil ).Twice ()
151
+ mockAcrClient .On ("GetAcrTags" , common .TestCtx , common .RepoName1 , "" , common .TagName4FloatingTag ).Return (common .EmptyListTagsResult , nil ).Twice ()
152
+ filteredRepositories , artifactsNotFound , err := ApplyFilterAndGetFilteredList (context .Background (), mockAcrClient , filter )
153
+ assert .NoError (t , err )
154
+ assert .Nil (t , artifactsNotFound )
155
+ assert .Len (t , artifactsNotFound , 0 )
156
+ assert .Len (t , filteredRepositories , 2 )
157
+ assert .True (t , isInFilteredList (filteredRepositories , common .RepoName1 , common .TagName1 , common .TagName1Incremental2 ))
158
+ assert .True (t , isInFilteredList (filteredRepositories , common .RepoName1 , common .TagName2 , common .TagName2Incremental2 ))
159
+ })
160
+ // 7. Success scenario with all the combination of filters when tag-convention is floating
106
161
t .Run ("AllFilterCombinationTestWithFloatingTagConvention" , func (t * testing.T ) {
107
162
filter := Filter {
108
163
Version : "v1" ,
@@ -152,7 +207,7 @@ func TestApplyFilterAndGetFilteredList(t *testing.T) {
152
207
assert .True (t , isInFilteredList (filteredRepositories , common .RepoName3 , common .TagName1 , common .TagName1FloatingTag ))
153
208
assert .True (t , isInFilteredList (filteredRepositories , common .RepoName3 , common .TagName2 , common .TagName2FloatingTag ))
154
209
})
155
- // 6 . Success scenario with all the combination of filters when tag-convention is empty (defaults to incremental)
210
+ // 7 . Success scenario with all the combination of filters when tag-convention is empty (defaults to incremental)
156
211
t .Run ("AllFilterCombinationTestWithIncrementalTagConvention" , func (t * testing.T ) {
157
212
filter := Filter {
158
213
Version : "v1" ,
0 commit comments