@@ -50,6 +50,7 @@ func TestGetContainers(t *testing.T) {
50
50
tests := []struct {
51
51
name string
52
52
containerComponents []v1.Component
53
+ filteredComponents []v1.Component
53
54
filterOptions common.DevfileOptions
54
55
wantContainerName string
55
56
wantContainerImage string
@@ -149,6 +150,17 @@ func TestGetContainers(t *testing.T) {
149
150
{
150
151
name : "Filter containers" ,
151
152
containerComponents : []v1.Component {
153
+ {
154
+ Name : containerNames [0 ],
155
+ ComponentUnion : v1.ComponentUnion {
156
+ Container : & v1.ContainerComponent {
157
+ Container : v1.Container {
158
+ Image : containerImages [0 ],
159
+ MountSources : & falseMountSources ,
160
+ },
161
+ },
162
+ },
163
+ },
152
164
{
153
165
Name : containerNames [1 ],
154
166
Attributes : attributes.Attributes {}.FromStringMap (map [string ]string {
@@ -167,6 +179,23 @@ func TestGetContainers(t *testing.T) {
167
179
},
168
180
wantContainerName : containerNames [1 ],
169
181
wantContainerImage : containerImages [0 ],
182
+ filteredComponents : []v1.Component {
183
+ {
184
+ Name : containerNames [1 ],
185
+ Attributes : attributes.Attributes {}.FromStringMap (map [string ]string {
186
+ "firstString" : "firstStringValue" ,
187
+ "thirdString" : "thirdStringValue" ,
188
+ }),
189
+ ComponentUnion : v1.ComponentUnion {
190
+ Container : & v1.ContainerComponent {
191
+ Container : v1.Container {
192
+ Image : containerImages [0 ],
193
+ MountSources : & falseMountSources ,
194
+ },
195
+ },
196
+ },
197
+ },
198
+ },
170
199
filterOptions : common.DevfileOptions {
171
200
Filter : map [string ]interface {}{
172
201
"firstString" : "firstStringValue" ,
@@ -182,7 +211,11 @@ func TestGetContainers(t *testing.T) {
182
211
mockDevfileData := data .NewMockDevfileData (ctrl )
183
212
184
213
// set up the mock data
185
- mockDevfileData .EXPECT ().GetDevfileContainerComponents (tt .filterOptions ).Return (tt .containerComponents , nil ).AnyTimes ()
214
+ if len (tt .filterOptions .Filter ) == 0 {
215
+ mockDevfileData .EXPECT ().GetDevfileContainerComponents (tt .filterOptions ).Return (tt .containerComponents , nil ).AnyTimes ()
216
+ } else {
217
+ mockDevfileData .EXPECT ().GetDevfileContainerComponents (tt .filterOptions ).Return (tt .filteredComponents , nil ).AnyTimes ()
218
+ }
186
219
mockDevfileData .EXPECT ().GetProjects (common.DevfileOptions {}).Return (projects , nil ).AnyTimes ()
187
220
188
221
devObj := parser.DevfileObj {
0 commit comments