Skip to content

Commit eccc3a2

Browse files
Skip test if SPANNER_DATABASE isn’t set
1 parent 51afccc commit eccc3a2

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

database/spanner/README.md

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

database/spanner/spanner_test.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@ import (
1010

1111
func Test(t *testing.T) {
1212
if testing.Short() {
13-
t.Skip("skipping testing Google Spanner during short testing")
13+
t.Skip("skipping test in short mode.")
14+
}
15+
16+
db, ok := os.LookupEnv("SPANNER_DATABASE")
17+
if !ok {
18+
t.Skip("SPANNER_DATABASE not set, skipping test.")
1419
}
1520

16-
db := os.Getenv("SPANNER_DATABASE")
1721
s := &Spanner{}
1822
addr := fmt.Sprintf("spanner://%v", db)
1923
d, err := s.Open(addr)

0 commit comments

Comments
 (0)