forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
org_and_space.go
63 lines (53 loc) · 1.62 KB
/
org_and_space.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package helpers
import (
"fmt"
"strings"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
)
func SetupReadOnlyOrgAndSpace() (string, string) {
homeDir := SetHomeDir()
SetAPI()
LoginCF()
orgName := NewOrgName()
spaceName1 := NewSpaceName()
spaceName2 := NewSpaceName()
Eventually(CF("create-org", orgName)).Should(Exit(0))
Eventually(CF("create-space", spaceName1, "-o", orgName)).Should(Exit(0))
Eventually(CF("create-space", spaceName2, "-o", orgName)).Should(Exit(0))
DestroyHomeDir(homeDir)
return orgName, spaceName1
}
func CreateOrgAndSpace(org string, space string) {
CreateOrg(org)
TargetOrg(org)
CreateSpace(space)
}
func CreateOrg(org string) {
Eventually(CF("create-org", org)).Should(Exit(0))
}
func CreateSpace(space string) {
Eventually(CF("create-space", space)).Should(Exit(0))
}
func GetOrgGUID(orgName string) string {
session := CF("org", "--guid", orgName)
Eventually(session).Should(Exit(0))
return strings.TrimSpace(string(session.Out.Contents()))
}
func GetSpaceGUID(spaceName string) string {
session := CF("space", "--guid", spaceName)
Eventually(session).Should(Exit(0))
return strings.TrimSpace(string(session.Out.Contents()))
}
func QuickDeleteOrg(orgName string) {
guid := GetOrgGUID(orgName)
url := fmt.Sprintf("/v2/organizations/%s?recursive=true&async=true", guid)
session := CF("curl", "-X", "DELETE", url)
Eventually(session).Should(Exit(0))
}
func QuickDeleteSpace(spaceName string) {
guid := GetSpaceGUID(spaceName)
url := fmt.Sprintf("/v2/spaces/%s?recursive=true&async=true", guid)
session := CF("curl", "-X", "DELETE", url)
Eventually(session).Should(Exit(0))
}