-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintegration_test.go
More file actions
91 lines (72 loc) · 2.53 KB
/
integration_test.go
File metadata and controls
91 lines (72 loc) · 2.53 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package main_test
import (
"os/exec"
"path/filepath"
"strings"
"time"
"github.com/cloudfoundry/gunk/runner_support"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/vito/cmdtest"
)
var _ = Describe("Integration Test for Org Space plugin", func() {
orgName := "testorg"
spaceName := "testspace"
BeforeEach(func() {
cfCmd := exec.Command("cf", "plugins")
session := runCommand(cfCmd)
if strings.Contains(string(session.FullOutput()), "OrgSpace") {
cfCmd := exec.Command("cf", "uninstall-plugin", "OrgSpace")
session := runCommand(cfCmd)
Expect(string(session.FullOutput())).NotTo(ContainSubstring("FAILED"))
}
plugin, filePathErr := filepath.Abs("org_space.exe")
Expect(filePathErr).ToNot(HaveOccurred())
cfCmd = exec.Command("cf", "install-plugin", plugin)
session = runCommand(cfCmd)
Expect(string(session.FullOutput())).NotTo(ContainSubstring("FAILED"))
})
AfterEach(func() {
cfCmd := exec.Command("cf", "uninstall-plugin", "OrgSpace")
session := runCommand(cfCmd)
Expect(string(session.FullOutput())).NotTo(ContainSubstring("FAILED"))
})
Context("when the org and space does not exist", func() {
BeforeEach(func() {
cfCmd := exec.Command("cf", "orgs")
session := runCommand(cfCmd)
if strings.Contains(string(session.FullOutput()), orgName) {
cfCmd := exec.Command("cf", "delete-org", orgName, "-f")
session := runCommand(cfCmd)
Expect(string(session.FullOutput())).NotTo(ContainSubstring("does not exist."))
}
})
AfterEach(func() {
cfCmd := exec.Command("cf", "delete-org", orgName, "-f")
session := runCommand(cfCmd)
Expect(string(session.FullOutput())).NotTo(ContainSubstring("does not exist."))
})
It("creates the org and space then targets it", func() {
cfCmd := exec.Command("cf", "org-space", orgName, spaceName)
session := runCommand(cfCmd)
Expect(string(session.FullOutput())).To(ContainSubstring("Org testorg and Space testspace is now available and targeted"))
cfCmd = exec.Command("cf", "orgs")
session = runCommand(cfCmd)
Expect(string(session.FullOutput())).To(ContainSubstring(orgName))
cfCmd = exec.Command("cf", "spaces")
session = runCommand(cfCmd)
Expect(string(session.FullOutput())).To(ContainSubstring(spaceName))
})
})
})
func runCommand(cmd *exec.Cmd) *cmdtest.Session {
session, err := cmdtest.StartWrapped(
cmd,
runner_support.TeeIfVerbose,
runner_support.TeeIfVerbose,
)
Expect(err).NotTo(HaveOccurred())
_, err = session.Wait(10 * time.Second)
Expect(err).NotTo(HaveOccurred())
return session
}