@@ -51,7 +51,7 @@ func TestExecPod(t *testing.T) {
51
51
t .Fatal (err )
52
52
}
53
53
54
- return ctx
54
+ return context . WithValue ( ctx , "test-deployment" , deployment )
55
55
}).
56
56
Assess ("check connectivity to wikipedia.org main page" , func (ctx context.Context , t * testing.T , c * envconf.Config ) context.Context {
57
57
client , err := c .NewClient ()
@@ -60,15 +60,15 @@ func TestExecPod(t *testing.T) {
60
60
}
61
61
62
62
pods := & corev1.PodList {}
63
- err = client .Resources (c .Namespace ()).List (context . TODO () , pods )
63
+ err = client .Resources (c .Namespace ()).List (ctx , pods )
64
64
if err != nil || pods .Items == nil {
65
65
t .Error ("error while getting pods" , err )
66
66
}
67
67
var stdout , stderr bytes.Buffer
68
68
podName := pods .Items [0 ].Name
69
69
command := []string {"curl" , "-I" , "https://en.wikipedia.org/wiki/Main_Page" }
70
70
71
- if err := client .Resources ().ExecInPod (context . TODO () , c .Namespace (), podName , containerName , command , & stdout , & stderr ); err != nil {
71
+ if err := client .Resources ().ExecInPod (ctx , c .Namespace (), podName , containerName , command , & stdout , & stderr ); err != nil {
72
72
t .Log (stderr .String ())
73
73
t .Fatal (err )
74
74
}
@@ -78,6 +78,13 @@ func TestExecPod(t *testing.T) {
78
78
t .Fatal ("Couldn't connect to en.wikipedia.org" )
79
79
}
80
80
return ctx
81
+ }).
82
+ Teardown (func (ctx context.Context , t * testing.T , c * envconf.Config ) context.Context {
83
+ dep := ctx .Value ("test-deployment" ).(* appsv1.Deployment )
84
+ if err := c .Client ().Resources ().Delete (ctx , dep ); err != nil {
85
+ t .Fatal (err )
86
+ }
87
+ return ctx
81
88
}).Feature ()
82
89
_ = testEnv .Test (t , feature )
83
90
}
0 commit comments