@@ -34,61 +34,19 @@ func TestProvider_impl(t *testing.T) {
34
34
var _ terraform.ResourceProvider = Provider ()
35
35
}
36
36
37
- func testAccPreCheck (t * testing.T ) {
38
- v := os .Getenv ("OVH_ENDPOINT" )
39
- if v == "" {
40
- t .Fatal ("OVH_ENDPOINT must be set for acceptance tests" )
41
- }
42
-
43
- v = os .Getenv ("OVH_APPLICATION_KEY" )
44
- if v == "" {
45
- t .Fatal ("OVH_APPLICATION_KEY must be set for acceptance tests" )
46
- }
47
-
48
- v = os .Getenv ("OVH_APPLICATION_SECRET" )
49
- if v == "" {
50
- t .Fatal ("OVH_APPLICATION_SECRET must be set for acceptance tests" )
51
- }
52
-
53
- v = os .Getenv ("OVH_CONSUMER_KEY" )
54
- if v == "" {
55
- t .Fatal ("OVH_CONSUMER_KEY must be set for acceptance tests" )
56
- }
57
-
58
- v = os .Getenv ("OVH_VRACK" )
59
- if v == "" {
60
- t .Fatal ("OVH_VRACK must be set for acceptance tests" )
61
- }
62
-
63
- v = os .Getenv ("OVH_PUBLIC_CLOUD" )
64
- if v == "" {
65
- t .Fatal ("OVH_PUBLIC_CLOUD must be set for acceptance tests" )
66
- }
67
-
68
- v = os .Getenv ("OVH_ZONE" )
69
- if v == "" {
70
- t .Fatal ("OVH_ZONE must be set for acceptance tests" )
71
- }
72
-
73
- v = os .Getenv ("OVH_IPLB_SERVICE" )
74
- if v == "" {
75
- t .Fatal ("OVH_IPLB_SERVICE must be set for acceptance tests" )
76
- }
77
-
78
- v = os .Getenv ("OVH_IP_BLOCK" )
79
- if v == "" {
80
- t .Fatal ("OVH_IP_BLOCK must be set for acceptance tests" )
81
- }
82
-
83
- v = os .Getenv ("OVH_IP" )
84
- if v == "" {
85
- t .Fatal ("OVH_IP must be set for acceptance tests" )
37
+ func checkEnv (t * testing.T , e string ) {
38
+ if os .Getenv (e ) == "" {
39
+ t .Fatalf ("%s must be set for acceptance tests" , e )
86
40
}
41
+ }
87
42
88
- v = os .Getenv ("OVH_IP_REVERSE" )
89
- if v == "" {
90
- t .Fatal ("OVH_IP_REVERSE must be set for acceptance tests" )
91
- }
43
+ // Checks that the environment variables needed to create the OVH API client
44
+ // are set and create the client right away.
45
+ 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" )
92
50
93
51
if testAccOVHClient == nil {
94
52
config := Config {
@@ -99,13 +57,57 @@ func testAccPreCheck(t *testing.T) {
99
57
}
100
58
101
59
if err := config .loadAndValidate (); err != nil {
102
- t .Fatalf ("couln 't load OVH Client: %s" , err )
60
+ t .Fatalf ("Couldn 't load OVH Client: %s" , err )
103
61
} else {
104
62
testAccOVHClient = config .OVHClient
105
63
}
106
64
}
107
65
}
108
66
67
+ // Checks that the environment variables needed for the /ip acceptance tests
68
+ // are set.
69
+ func testAccPreCheckIp (t * testing.T ) {
70
+ testAccPreCheckCredentials (t )
71
+ checkEnv (t , "OVH_IP" )
72
+ checkEnv (t , "OVH_IP_BLOCK" )
73
+ checkEnv (t , "OVH_IP_REVERSE" )
74
+ }
75
+
76
+ // Checks that the environment variables needed for the /domain acceptance tests
77
+ // are set.
78
+ func testAccPreCheckDomain (t * testing.T ) {
79
+ testAccPreCheckCredentials (t )
80
+ checkEnv (t , "OVH_ZONE" )
81
+ }
82
+
83
+ // Checks that the environment variables needed for the /cloud acceptance tests
84
+ // are set.
85
+ func testAccPreCheckPublicCloud (t * testing.T ) {
86
+ testAccPreCheckCredentials (t )
87
+ checkEnv (t , "OVH_PUBLIC_CLOUD" )
88
+ }
89
+
90
+ // Checks that the environment variables needed for the /ipLoadbalacing acceptance tests
91
+ // are set.
92
+ func testAccPreCheckIpLoadbalancing (t * testing.T ) {
93
+ testAccPreCheckCredentials (t )
94
+ checkEnv (t , "OVH_IPLB_SERVICE" )
95
+ }
96
+
97
+ // Checks that the environment variables needed for the /vrack acceptance tests
98
+ // are set.
99
+ func testAccPreCheckVRack (t * testing.T ) {
100
+ testAccPreCheckCredentials (t )
101
+ checkEnv (t , "OVH_VRACK" )
102
+ }
103
+
104
+ // Checks that the environment variables needed for the /me/paymentMean acceptance tests
105
+ // are set.
106
+ func testAccPreCheckMePaymentMean (t * testing.T ) {
107
+ testAccPreCheckCredentials (t )
108
+ checkEnv (t , "OVH_TEST_BANKACCOUNT" )
109
+ }
110
+
109
111
func testAccCheckVRackExists (t * testing.T ) {
110
112
type vrackResponse struct {
111
113
Name string `json:"name"`
0 commit comments