Skip to content

Commit 0caeed9

Browse files
committed
Update filtered test
Signed-off-by: Maysun J Faisal <[email protected]>
1 parent 5a2ea56 commit 0caeed9

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

pkg/devfile/generator/generators_test.go

+34-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ func TestGetContainers(t *testing.T) {
5050
tests := []struct {
5151
name string
5252
containerComponents []v1.Component
53+
filteredComponents []v1.Component
5354
filterOptions common.DevfileOptions
5455
wantContainerName string
5556
wantContainerImage string
@@ -149,6 +150,17 @@ func TestGetContainers(t *testing.T) {
149150
{
150151
name: "Filter containers",
151152
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+
},
152164
{
153165
Name: containerNames[1],
154166
Attributes: attributes.Attributes{}.FromStringMap(map[string]string{
@@ -167,6 +179,23 @@ func TestGetContainers(t *testing.T) {
167179
},
168180
wantContainerName: containerNames[1],
169181
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+
},
170199
filterOptions: common.DevfileOptions{
171200
Filter: map[string]interface{}{
172201
"firstString": "firstStringValue",
@@ -182,7 +211,11 @@ func TestGetContainers(t *testing.T) {
182211
mockDevfileData := data.NewMockDevfileData(ctrl)
183212

184213
// 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+
}
186219
mockDevfileData.EXPECT().GetProjects(common.DevfileOptions{}).Return(projects, nil).AnyTimes()
187220

188221
devObj := parser.DevfileObj{

0 commit comments

Comments
 (0)