From eccc3a26d2bdde375a047ee443b13c883082f244 Mon Sep 17 00:00:00 2001 From: Christian Klotz Date: Tue, 20 Jun 2017 17:53:41 +0100 Subject: [PATCH] =?UTF-8?q?Skip=20test=20if=20SPANNER=5FDATABASE=20isn?= =?UTF-8?q?=E2=80=99t=20set?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- database/spanner/README.md | 8 +++++++- database/spanner/spanner_test.go | 8 ++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/database/spanner/README.md b/database/spanner/README.md index 195b214..0de867a 100644 --- a/database/spanner/README.md +++ b/database/spanner/README.md @@ -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) \ No newline at end of file +> 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. \ No newline at end of file diff --git a/database/spanner/spanner_test.go b/database/spanner/spanner_test.go index 6e6c44f..43d475c 100644 --- a/database/spanner/spanner_test.go +++ b/database/spanner/spanner_test.go @@ -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)