spanner: ITs don't check app credentials for emulator.
Change-Id: Id267f654058334512a081952d71330bf5521033b
Reviewed-on: https://code-review.googlesource.com/c/gocloud/+/53090
Reviewed-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Shanika Kuruppu <skuruppu@google.com>
diff --git a/spanner/integration_test.go b/spanner/integration_test.go
index 7437f45..f034e29 100644
--- a/spanner/integration_test.go
+++ b/spanner/integration_test.go
@@ -147,28 +147,29 @@
return noop
}
- ts := testutil.TokenSource(ctx, AdminScope, Scope)
- if ts == nil {
- log.Printf("Integration test skipped: cannot get service account credential from environment variable %v", "GCLOUD_TESTS_GOLANG_KEY")
- return noop
- }
- var err error
-
- opts := append(grpcHeaderChecker.CallOptions(), option.WithTokenSource(ts), option.WithEndpoint(endpoint))
-
+ opts := grpcHeaderChecker.CallOptions()
// Run integration tests against the given emulator. Currently, the database and
// instance admin clients are auto-generated, which do not support to configure
// SPANNER_EMULATOR_HOST.
emulatorAddr := os.Getenv("SPANNER_EMULATOR_HOST")
if emulatorAddr != "" {
opts = append(
- grpcHeaderChecker.CallOptions(),
+ opts,
option.WithEndpoint(emulatorAddr),
option.WithGRPCDialOption(grpc.WithInsecure()),
option.WithoutAuthentication(),
)
+ } else {
+ ts := testutil.TokenSource(ctx, AdminScope, Scope)
+ if ts == nil {
+ log.Printf("Integration test skipped: cannot get service account credential from environment variable %v", "GCLOUD_TESTS_GOLANG_KEY")
+ return noop
+ }
+
+ opts = append(opts, option.WithTokenSource(ts), option.WithEndpoint(endpoint))
}
+ var err error
// Create InstanceAdmin and DatabaseAdmin clients.
instanceAdmin, err = instance.NewInstanceAdminClient(ctx, opts...)
if err != nil {