provider/google: Allow acctests to set credentials via file

Makes things easier on Travis.
This commit is contained in:
Paul Hinze 2016-01-04 13:19:46 -06:00
parent 7b9f6e5128
commit 5e9e22d4fd
1 changed files with 9 additions and 0 deletions

View File

@ -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")
}