Skip test if SPANNER_DATABASE isn’t set

This commit is contained in:
Christian Klotz 2017-06-20 17:53:41 +01:00
parent 51afcccb6b
commit eccc3a26d2
2 changed files with 13 additions and 3 deletions

View File

@ -26,4 +26,10 @@ See [Google Spanner Documentation](https://cloud.google.com/spanner/docs) for de
> 1481574547/u create_users_table (21.354507597s)
> 1496539702/u add_city_to_users (41.647359754s)
> 1496601752/u add_index_on_user_emails (2m12.155787369s)
> 1496602638/u create_books_table (2m30.77299181s)
> 1496602638/u create_books_table (2m30.77299181s)
## Testing
To unit test the `spanner` driver, `SPANNER_DATABASE` needs to be set. You'll
need to sign-up to Google Cloud Platform (GCP) and have a running Spanner
instance since it is not possible to run Google Spanner outside GCP.

View File

@ -10,10 +10,14 @@ import (
func Test(t *testing.T) {
if testing.Short() {
t.Skip("skipping testing Google Spanner during short testing")
t.Skip("skipping test in short mode.")
}
db, ok := os.LookupEnv("SPANNER_DATABASE")
if !ok {
t.Skip("SPANNER_DATABASE not set, skipping test.")
}
db := os.Getenv("SPANNER_DATABASE")
s := &Spanner{}
addr := fmt.Sprintf("spanner://%v", db)
d, err := s.Open(addr)