provider/google: Allow acctests to set credentials via file
Makes things easier on Travis.
This commit is contained in:
parent
7b9f6e5128
commit
5e9e22d4fd
|
@ -1,6 +1,7 @@
|
||||||
package google
|
package google
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -29,6 +30,14 @@ func TestProvider_impl(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccPreCheck(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 == "" {
|
if v := os.Getenv("GOOGLE_CREDENTIALS"); v == "" {
|
||||||
t.Fatal("GOOGLE_CREDENTIALS must be set for acceptance tests")
|
t.Fatal("GOOGLE_CREDENTIALS must be set for acceptance tests")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue