File tree 2 files changed +24
-0
lines changed
third_party/terraform/utils
2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -48,3 +48,18 @@ func TestConfigLoadAndValidate_accountFileJSONInvalid(t *testing.T) {
48
48
t .Fatalf ("expected error, but got nil" )
49
49
}
50
50
}
51
+
52
+ func TestConfigLoadValidate_accessToken (t * testing.T ) {
53
+ accessToken := getTestAccessTokenFromEnv (t )
54
+
55
+ config := Config {
56
+ AccessToken : accessToken ,
57
+ Project : "my-gce-project" ,
58
+ Region : "us-central1" ,
59
+ }
60
+
61
+ err := config .loadAndValidate ()
62
+ if err != nil {
63
+ t .Fatalf ("error: %v" , err )
64
+ }
65
+ }
Original file line number Diff line number Diff line change @@ -57,6 +57,10 @@ var billingAccountEnvVars = []string{
57
57
"GOOGLE_BILLING_ACCOUNT" ,
58
58
}
59
59
60
+ var accessTokenEnvVars = []string {
61
+ "GOOGLE_OAUTH2_ACCESS_TOKEN" ,
62
+ }
63
+
60
64
func init () {
61
65
testAccProvider = Provider ().(* schema.Provider )
62
66
testAccRandomProvider = random .Provider ().(* schema.Provider )
@@ -202,6 +206,11 @@ func getTestServiceAccountFromEnv(t *testing.T) string {
202
206
return multiEnvSearch (serviceAccountEnvVars )
203
207
}
204
208
209
+ func getTestAccessTokenFromEnv (t * testing.T ) string {
210
+ skipIfEnvNotSet (t , accessTokenEnvVars ... )
211
+ return multiEnvSearch (accessTokenEnvVars )
212
+ }
213
+
205
214
func multiEnvSearch (ks []string ) string {
206
215
for _ , k := range ks {
207
216
if v := os .Getenv (k ); v != "" {
You can’t perform that action at this time.
0 commit comments