-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexec_test.go
46 lines (36 loc) · 845 Bytes
/
exec_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package k8t_test
import (
"os"
"strings"
"testing"
"github.com/sn3d/k8t"
)
func Test_Exec(t *testing.T) {
if os.Getenv("KUBECONFIG") == "" {
t.Skip("No KUBECONFIG defined")
}
// GIVEN: cluster with busybox pod deployed
cluster, err := k8t.NewFromEnvironment()
if err != nil {
t.FailNow()
}
err = cluster.ApplyFile("testdata/test-agent.yaml")
if err != nil {
t.FailNow()
}
err = cluster.WaitFor(k8t.PodIsRunning("", "test-agent"))
if err != nil {
t.FailNow()
}
// WHEN: we executes 'echo' command in pod
result := cluster.Execf("test-agent", "test-container", "echo %s", "hello-world")
// THEN: the result has no error
if result.Err != nil {
t.FailNow()
}
// AND: the output should contain the echo-ed text
output := strings.Trim(result.String(), " \n")
if output == "hello-world" {
t.FailNow()
}
}