@@ -36,44 +36,44 @@ var (
36
36
testDomainPath string // Needed in before and in after suite.
37
37
)
38
38
39
- var _ = BeforeSuite (func () {
40
- // Create a real cloud client.
41
- projDir := os .Getenv ("PROJECT_DIR" )
42
- var connectionErr error
43
- realCloudClient , connectionErr = cloud .NewClient (projDir + "/cloud-config" )
44
- Ω (connectionErr ).ShouldNot (HaveOccurred ())
45
-
46
- // Create a real CloudStack client.
47
- realCSClient , connectionErr = helpers .NewCSClient ()
48
- Ω (connectionErr ).ShouldNot (HaveOccurred ())
49
-
50
- // Create a new account and user to run tests that use a real ACS instance.
51
- uid := string (uuid .NewUUID ())
52
- newAccount := cloud.Account {
53
- Name : "TestAccount-" + uid ,
54
- Domain : cloud.Domain {Name : "TestDomain-" + uid , Path : "ROOT/TestDomain-" + uid }}
55
- newUser := cloud.User {Account : newAccount }
56
- Ω (helpers .GetOrCreateUserWithKey (realCSClient , & newUser )).Should (Succeed ())
57
- testDomainPath = newAccount .Domain .Path
39
+ func TestCloud (t * testing.T ) {
40
+ RegisterFailHandler (Fail )
41
+ BeforeSuite (func () {
42
+ // Create a real cloud client.
43
+ projDir := os .Getenv ("PROJECT_DIR" )
44
+ var connectionErr error
45
+ realCloudClient , connectionErr = cloud .NewClient (projDir + "/cloud-config" )
46
+ Ω (connectionErr ).ShouldNot (HaveOccured ())
58
47
59
- Ω (newUser .APIKey ).ShouldNot (BeEmpty ())
48
+ // Create a real CloudStack client.
49
+ realCSClient , connectionErr = helpers .NewCSClient ()
50
+ Ω (connectionErr ).ShouldNot (HaveOccurred ())
60
51
61
- // Switch to test account user.
62
- cfg := cloud.Config {APIKey : newUser .APIKey , SecretKey : newUser .SecretKey }
63
- realCloudClient , connectionErr = realCloudClient .NewClientFromSpec (cfg )
64
- Ω (connectionErr ).ShouldNot (HaveOccurred ())
65
- })
52
+ // Create a new account and user to run tests that use a real ACS instance.
53
+ uid := string (uuid .NewUUID ())
54
+ newAccount := cloud.Account {
55
+ Name : "TestAccount-" + uid ,
56
+ Domain : cloud.Domain {Name : "TestDomain-" + uid , Path : "ROOT/TestDomain-" + uid }}
57
+ newUser := cloud.User {Account : newAccount }
58
+ Ω (helpers .GetOrCreateUserWithKey (realCSClient , & newUser )).Should (Succeed ())
59
+ testDomainPath = newAccount .Domain .Path
66
60
67
- var _ = AfterSuite (func () {
68
- // Delete created domain.
69
- id , err , found := helpers .GetDomainByPath (realCSClient , testDomainPath )
70
- Ω (err ).ShouldNot (HaveOccurred ())
71
- Ω (found ).Should (BeTrue ())
72
- Ω (helpers .DeleteDomain (realCSClient , id )).Should (Succeed ())
73
- })
61
+ Ω (newUser .APIKey ).ShouldNot (BeEmpty ())
74
62
75
- func TestCloud (t * testing.T ) {
76
- RegisterFailHandler (Fail )
63
+ // Switch to test account user.
64
+ cfg := cloud.Config {APIKey : newUser .APIKey , SecretKey : newUser .SecretKey }
65
+ realCloudClient , connectionErr = realCloudClient .NewClientFromSpec (cfg )
66
+ Ω (connectionErr ).ShouldNot (HaveOccurred ())
67
+ })
68
+ AfterSuite (func () {
69
+ if realCSClient != nil { // Check for nil in case the before suite setup failed.
70
+ // Delete created domain.
71
+ id , err , found := helpers .GetDomainByPath (realCSClient , testDomainPath )
72
+ Ω (err ).ShouldNot (HaveOccurred ())
73
+ Ω (found ).Should (BeTrue ())
74
+ Ω (helpers .DeleteDomain (realCSClient , id )).Should (Succeed ())
75
+ }
76
+ })
77
77
RunSpecs (t , "Cloud Suite" )
78
78
}
79
79
0 commit comments