From 5e9e22d4fd8c11ad3560ab75cdbf093fd1e31add Mon Sep 17 00:00:00 2001 From: Paul Hinze Date: Mon, 4 Jan 2016 13:19:46 -0600 Subject: [PATCH] provider/google: Allow acctests to set credentials via file Makes things easier on Travis. --- builtin/providers/google/provider_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/builtin/providers/google/provider_test.go b/builtin/providers/google/provider_test.go index 827a7f575..51654a668 100644 --- a/builtin/providers/google/provider_test.go +++ b/builtin/providers/google/provider_test.go @@ -1,6 +1,7 @@ package google import ( + "io/ioutil" "os" "testing" @@ -29,6 +30,14 @@ func TestProvider_impl(t *testing.T) { } func testAccPreCheck(t *testing.T) { + if v := os.Getenv("GOOGLE_CREDENTIALS_FILE"); v != "" { + creds, err := ioutil.ReadFile(v) + if err != nil { + t.Fatalf("Error reading GOOGLE_CREDENTIALS_FILE path: %s", err) + } + os.Setenv("GOOGLE_CREDENTIALS", string(creds)) + } + if v := os.Getenv("GOOGLE_CREDENTIALS"); v == "" { t.Fatal("GOOGLE_CREDENTIALS must be set for acceptance tests") }