@@ -52,7 +52,7 @@ func TestGetContainers(t *testing.T) {
5252 wantErr bool
5353 }{
5454 {
55- name : "Case 1: Container with default project root" ,
55+ name : "Container with default project root" ,
5656 containerComponents : []v1.Component {
5757 {
5858 Name : containerNames [0 ],
@@ -87,7 +87,7 @@ func TestGetContainers(t *testing.T) {
8787 },
8888 },
8989 {
90- name : "Case 2: Container with source mapping" ,
90+ name : "Container with source mapping" ,
9191 containerComponents : []v1.Component {
9292 {
9393 Name : containerNames [0 ],
@@ -123,7 +123,7 @@ func TestGetContainers(t *testing.T) {
123123 },
124124 },
125125 {
126- name : "Case 3: Container with no mount source" ,
126+ name : "Container with no mount source" ,
127127 containerComponents : []v1.Component {
128128 {
129129 Name : containerNames [0 ],
@@ -141,7 +141,7 @@ func TestGetContainers(t *testing.T) {
141141 wantContainerImage : containerImages [0 ],
142142 },
143143 {
144- name : "Case 4: Filter containers" ,
144+ name : "Filter containers" ,
145145 containerComponents : []v1.Component {
146146 {
147147 Name : containerNames [0 ],
@@ -201,26 +201,20 @@ func TestGetContainers(t *testing.T) {
201201 // Unexpected error
202202 if (err != nil ) != tt .wantErr {
203203 t .Errorf ("TestGetContainers() error = %v, wantErr %v" , err , tt .wantErr )
204- return
205- }
206-
207- // Expected error and got an err
208- if tt .wantErr && err != nil {
209- return
210- }
211-
212- for _ , container := range containers {
213- if container .Name != tt .wantContainerName {
214- t .Errorf ("TestGetContainers error: Name mismatch - got: %s, wanted: %s" , container .Name , tt .wantContainerName )
215- }
216- if container .Image != tt .wantContainerImage {
217- t .Errorf ("TestGetContainers error: Image mismatch - got: %s, wanted: %s" , container .Image , tt .wantContainerImage )
218- }
219- if len (container .Env ) > 0 && ! reflect .DeepEqual (container .Env , tt .wantContainerEnv ) {
220- t .Errorf ("TestGetContainers error: Env mismatch - got: %+v, wanted: %+v" , container .Env , tt .wantContainerEnv )
221- }
222- if len (container .VolumeMounts ) > 0 && ! reflect .DeepEqual (container .VolumeMounts , tt .wantContainerVolMount ) {
223- t .Errorf ("TestGetContainers error: Vol Mount mismatch - got: %+v, wanted: %+v" , container .VolumeMounts , tt .wantContainerVolMount )
204+ } else if err == nil {
205+ for _ , container := range containers {
206+ if container .Name != tt .wantContainerName {
207+ t .Errorf ("TestGetContainers error: Name mismatch - got: %s, wanted: %s" , container .Name , tt .wantContainerName )
208+ }
209+ if container .Image != tt .wantContainerImage {
210+ t .Errorf ("TestGetContainers error: Image mismatch - got: %s, wanted: %s" , container .Image , tt .wantContainerImage )
211+ }
212+ if len (container .Env ) > 0 && ! reflect .DeepEqual (container .Env , tt .wantContainerEnv ) {
213+ t .Errorf ("TestGetContainers error: Env mismatch - got: %+v, wanted: %+v" , container .Env , tt .wantContainerEnv )
214+ }
215+ if len (container .VolumeMounts ) > 0 && ! reflect .DeepEqual (container .VolumeMounts , tt .wantContainerVolMount ) {
216+ t .Errorf ("TestGetContainers error: Vol Mount mismatch - got: %+v, wanted: %+v" , container .VolumeMounts , tt .wantContainerVolMount )
217+ }
224218 }
225219 }
226220 })
0 commit comments