@@ -25,6 +25,7 @@ import (
25
25
"net"
26
26
"net/http"
27
27
"net/url"
28
+ "path"
28
29
"path/filepath"
29
30
"strings"
30
31
"testing"
@@ -131,12 +132,16 @@ func testIngressController(t *testing.T) {
131
132
t .Fatalf ("waiting for default-http-backend to be up: %v" , err )
132
133
}
133
134
134
- ingressPath , _ := filepath .Abs ("testdata/nginx-ing.yaml" )
135
+ curdir , err := filepath .Abs ("" )
136
+ if err != nil {
137
+ t .Errorf ("Error getting the file path for current directory: %s" , curdir )
138
+ }
139
+ ingressPath := path .Join (curdir , "testdata" , "nginx-ing.yaml" )
135
140
if _ , err := kubectlRunner .RunCommand ([]string {"create" , "-f" , ingressPath }); err != nil {
136
141
t .Fatalf ("creating nginx ingress resource: %v" , err )
137
142
}
138
143
139
- podPath , _ := filepath . Abs ( "testdata/ nginx-pod-svc.yaml" )
144
+ podPath := path . Join ( curdir , "testdata" , " nginx-pod-svc.yaml" )
140
145
if _ , err := kubectlRunner .RunCommand ([]string {"create" , "-f" , podPath }); err != nil {
141
146
t .Fatalf ("creating nginx ingress resource: %v" , err )
142
147
}
@@ -248,7 +253,11 @@ func testGvisorRestart(t *testing.T) {
248
253
249
254
func createUntrustedWorkload (t * testing.T ) {
250
255
kubectlRunner := util .NewKubectlRunner (t )
251
- untrustedPath , _ := filepath .Abs ("testdata/nginx-untrusted.yaml" )
256
+ curdir , err := filepath .Abs ("" )
257
+ if err != nil {
258
+ t .Errorf ("Error getting the file path for current directory: %s" , curdir )
259
+ }
260
+ untrustedPath := path .Join (curdir , "testdata" , "nginx-untrusted.yaml" )
252
261
t .Log ("creating pod with untrusted workload annotation" )
253
262
if _ , err := kubectlRunner .RunCommand ([]string {"replace" , "-f" , untrustedPath , "--force" }); err != nil {
254
263
t .Fatalf ("creating untrusted nginx resource: %v" , err )
@@ -257,7 +266,11 @@ func createUntrustedWorkload(t *testing.T) {
257
266
258
267
func deleteUntrustedWorkload (t * testing.T ) {
259
268
kubectlRunner := util .NewKubectlRunner (t )
260
- untrustedPath , _ := filepath .Abs ("testdata/nginx-untrusted.yaml" )
269
+ curdir , err := filepath .Abs ("" )
270
+ if err != nil {
271
+ t .Errorf ("Error getting the file path for current directory: %s" , curdir )
272
+ }
273
+ untrustedPath := path .Join (curdir , "testdata" , "nginx-untrusted.yaml" )
261
274
if _ , err := kubectlRunner .RunCommand ([]string {"delete" , "-f" , untrustedPath }); err != nil {
262
275
t .Logf ("error deleting untrusted nginx resource: %v" , err )
263
276
}
0 commit comments