Skip to content

Commit fa12754

Browse files
committed
add tests
1 parent 7b2c33e commit fa12754

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

third_party/terraform/utils/config_test.go

+15
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,18 @@ func TestConfigLoadAndValidate_accountFileJSONInvalid(t *testing.T) {
4848
t.Fatalf("expected error, but got nil")
4949
}
5050
}
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+
}

third_party/terraform/utils/provider_test.go

+9
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ var billingAccountEnvVars = []string{
5757
"GOOGLE_BILLING_ACCOUNT",
5858
}
5959

60+
var accessTokenEnvVars = []string{
61+
"GOOGLE_OAUTH2_ACCESS_TOKEN",
62+
}
63+
6064
func init() {
6165
testAccProvider = Provider().(*schema.Provider)
6266
testAccRandomProvider = random.Provider().(*schema.Provider)
@@ -202,6 +206,11 @@ func getTestServiceAccountFromEnv(t *testing.T) string {
202206
return multiEnvSearch(serviceAccountEnvVars)
203207
}
204208

209+
func getTestAccessTokenFromEnv(t *testing.T) string {
210+
skipIfEnvNotSet(t, accessTokenEnvVars...)
211+
return multiEnvSearch(accessTokenEnvVars)
212+
}
213+
205214
func multiEnvSearch(ks []string) string {
206215
for _, k := range ks {
207216
if v := os.Getenv(k); v != "" {

0 commit comments

Comments
 (0)