forked from alex8866/kubernetes-testing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsvc_test.go
More file actions
39 lines (36 loc) · 1.27 KB
/
svc_test.go
File metadata and controls
39 lines (36 loc) · 1.27 KB
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
package main
import (
"os/exec"
"path/filepath"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestKubeServices(t *testing.T) {
Convey("Subject: Test kube services", t, func() {
file := filepath.Join("files", "frontend-service.yaml")
Convey("Subject: Creating service should be successful", func() {
Convey("Given the service 'frontend' is not existed yet", func() {
Convey("When run kubectl create -f frontend-service.yaml", func() {
output, err := exec.Command("kubectl", "create", "-f", file).Output()
Convey("it should return service 'frontend' created", func() {
So(string(output), ShouldContainSubstring, "created")
So(string(output), ShouldContainSubstring, "frontend")
So(err, ShouldBeNil)
})
})
})
})
Convey("Subject: Deleting service should be successful.", func() {
Convey("Given service 'frontend' is existing", func() {
Convey("When run kubectl delete svc frontend", func() {
output, err := exec.Command("kubectl", "delete", "-f", file).Output()
Convey("it should return service 'frontend' deleted", func() {
So(string(output), ShouldContainSubstring, "deleted")
So(string(output), ShouldContainSubstring, "frontend")
So(err, ShouldBeNil)
})
})
})
})
})
}