@@ -34,19 +34,25 @@ func TestProvider_impl(t *testing.T) {
34
34
var _ terraform.ResourceProvider = Provider ()
35
35
}
36
36
37
- func checkEnv (t * testing.T , e string ) {
37
+ func checkEnvOrFail (t * testing.T , e string ) {
38
38
if os .Getenv (e ) == "" {
39
39
t .Fatalf ("%s must be set for acceptance tests" , e )
40
40
}
41
41
}
42
42
43
+ func checkEnvOrSkip (t * testing.T , e string ) {
44
+ if os .Getenv (e ) == "" {
45
+ t .Skipf ("[WARN] %s must be set for acceptance tests. Skipping." , e )
46
+ }
47
+ }
48
+
43
49
// Checks that the environment variables needed to create the OVH API client
44
50
// are set and create the client right away.
45
51
func testAccPreCheckCredentials (t * testing.T ) {
46
- checkEnv (t , "OVH_ENDPOINT" )
47
- checkEnv (t , "OVH_APPLICATION_KEY" )
48
- checkEnv (t , "OVH_APPLICATION_SECRET" )
49
- checkEnv (t , "OVH_CONSUMER_KEY" )
52
+ checkEnvOrFail (t , "OVH_ENDPOINT" )
53
+ checkEnvOrFail (t , "OVH_APPLICATION_KEY" )
54
+ checkEnvOrFail (t , "OVH_APPLICATION_SECRET" )
55
+ checkEnvOrFail (t , "OVH_CONSUMER_KEY" )
50
56
51
57
if testAccOVHClient == nil {
52
58
config := Config {
@@ -68,44 +74,44 @@ func testAccPreCheckCredentials(t *testing.T) {
68
74
// are set.
69
75
func testAccPreCheckIp (t * testing.T ) {
70
76
testAccPreCheckCredentials (t )
71
- checkEnv (t , "OVH_IP" )
72
- checkEnv (t , "OVH_IP_BLOCK" )
73
- checkEnv (t , "OVH_IP_REVERSE" )
77
+ checkEnvOrSkip (t , "OVH_IP" )
78
+ checkEnvOrSkip (t , "OVH_IP_BLOCK" )
79
+ checkEnvOrSkip (t , "OVH_IP_REVERSE" )
74
80
}
75
81
76
82
// Checks that the environment variables needed for the /domain acceptance tests
77
83
// are set.
78
84
func testAccPreCheckDomain (t * testing.T ) {
79
85
testAccPreCheckCredentials (t )
80
- checkEnv (t , "OVH_ZONE" )
86
+ checkEnvOrSkip (t , "OVH_ZONE" )
81
87
}
82
88
83
89
// Checks that the environment variables needed for the /cloud acceptance tests
84
90
// are set.
85
91
func testAccPreCheckPublicCloud (t * testing.T ) {
86
92
testAccPreCheckCredentials (t )
87
- checkEnv (t , "OVH_PUBLIC_CLOUD" )
93
+ checkEnvOrSkip (t , "OVH_PUBLIC_CLOUD" )
88
94
}
89
95
90
96
// Checks that the environment variables needed for the /ipLoadbalacing acceptance tests
91
97
// are set.
92
98
func testAccPreCheckIpLoadbalancing (t * testing.T ) {
93
99
testAccPreCheckCredentials (t )
94
- checkEnv (t , "OVH_IPLB_SERVICE" )
100
+ checkEnvOrSkip (t , "OVH_IPLB_SERVICE" )
95
101
}
96
102
97
103
// Checks that the environment variables needed for the /vrack acceptance tests
98
104
// are set.
99
105
func testAccPreCheckVRack (t * testing.T ) {
100
106
testAccPreCheckCredentials (t )
101
- checkEnv (t , "OVH_VRACK" )
107
+ checkEnvOrSkip (t , "OVH_VRACK" )
102
108
}
103
109
104
110
// Checks that the environment variables needed for the /me/paymentMean acceptance tests
105
111
// are set.
106
112
func testAccPreCheckMePaymentMean (t * testing.T ) {
107
113
testAccPreCheckCredentials (t )
108
- checkEnv (t , "OVH_TEST_BANKACCOUNT" )
114
+ checkEnvOrSkip (t , "OVH_TEST_BANKACCOUNT" )
109
115
}
110
116
111
117
func testAccCheckVRackExists (t * testing.T ) {
@@ -142,7 +148,6 @@ func testAccCheckPublicCloudExists(t *testing.T) {
142
148
t .Fatalf ("Error: %q\n " , err )
143
149
}
144
150
t .Logf ("Read Cloud Project %s -> status: '%s', desc: '%s'" , endpoint , r .Status , r .Description )
145
-
146
151
}
147
152
148
153
func testAccCheckIpLoadbalancingExists (t * testing.T ) {
@@ -160,7 +165,6 @@ func testAccCheckIpLoadbalancingExists(t *testing.T) {
160
165
t .Fatalf ("Error: %q\n " , err )
161
166
}
162
167
t .Logf ("Read IPLB service %s -> state: '%s', serviceName: '%s'" , endpoint , r .State , r .ServiceName )
163
-
164
168
}
165
169
166
170
func testAccCheckDomainZoneExists (t * testing.T ) {
0 commit comments