@@ -102,6 +102,14 @@ func TestPodAndContainerAttach(t *testing.T) {
102
102
expectedContainerName : "initfoo" ,
103
103
obj : attachPod (),
104
104
},
105
+ {
106
+ name : "ephemeral container in flag" ,
107
+ options : & AttachOptions {StreamOptions : exec.StreamOptions {ContainerName : "debugger" }, GetPodTimeout : 30 },
108
+ args : []string {"foo" },
109
+ expectedPodName : "foo" ,
110
+ expectedContainerName : "debugger" ,
111
+ obj : attachPod (),
112
+ },
105
113
{
106
114
name : "non-existing container" ,
107
115
options : & AttachOptions {StreamOptions : exec.StreamOptions {ContainerName : "wrong" }, GetPodTimeout : 10 },
@@ -136,7 +144,7 @@ func TestPodAndContainerAttach(t *testing.T) {
136
144
test .options .Resources = test .args
137
145
138
146
if err := test .options .Validate (); err != nil {
139
- if ! strings .Contains (err .Error (), test .expectError ) {
147
+ if test . expectError == "" || ! strings .Contains (err .Error (), test .expectError ) {
140
148
t .Errorf ("unexpected error: expected %q, got %q" , test .expectError , err )
141
149
}
142
150
return
@@ -153,7 +161,7 @@ func TestPodAndContainerAttach(t *testing.T) {
153
161
},
154
162
})
155
163
if err != nil {
156
- if ! strings .Contains (err .Error (), test .expectError ) {
164
+ if test . expectError == "" || ! strings .Contains (err .Error (), test .expectError ) {
157
165
t .Errorf ("unexpected error: expected %q, got %q" , err , test .expectError )
158
166
}
159
167
return
@@ -165,7 +173,7 @@ func TestPodAndContainerAttach(t *testing.T) {
165
173
166
174
container , err := test .options .containerToAttachTo (attachPod ())
167
175
if err != nil {
168
- if ! strings .Contains (err .Error (), test .expectError ) {
176
+ if test . expectError == "" || ! strings .Contains (err .Error (), test .expectError ) {
169
177
t .Errorf ("unexpected error: expected %q, got %q" , err , test .expectError )
170
178
}
171
179
return
@@ -414,6 +422,13 @@ func attachPod() *corev1.Pod {
414
422
Name : "initfoo" ,
415
423
},
416
424
},
425
+ EphemeralContainers : []corev1.EphemeralContainer {
426
+ {
427
+ EphemeralContainerCommon : corev1.EphemeralContainerCommon {
428
+ Name : "debugger" ,
429
+ },
430
+ },
431
+ },
417
432
},
418
433
Status : corev1.PodStatus {
419
434
Phase : corev1 .PodRunning ,
0 commit comments