spanner: check for existence of status

BatchDML from Cloud Spanner will normally return a Status.OK value
when all statements executed successfully. The emulator does however
not return a status code when all statements executed successfully,
which caused a panic because the client library expected the status
code to always be returned.

Fixes #2210

Change-Id: I604f2d5c4d67d4767ad562dd58b52e3d5effd6c8
Reviewed-on: https://code-review.googlesource.com/c/gocloud/+/56792
Reviewed-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hengfeng Li <hengfeng@google.com>
diff --git a/spanner/integration_test.go b/spanner/integration_test.go
index 7aa311b..32464a7 100644
--- a/spanner/integration_test.go
+++ b/spanner/integration_test.go
@@ -2500,7 +2500,6 @@
 }
 
 func TestIntegration_BatchDML(t *testing.T) {
-	skipEmulatorTest(t)
 	t.Parallel()
 
 	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
@@ -2578,7 +2577,6 @@
 }
 
 func TestIntegration_BatchDML_TwoStatements(t *testing.T) {
-	skipEmulatorTest(t)
 	t.Parallel()
 
 	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
diff --git a/spanner/transaction.go b/spanner/transaction.go
index 5199263..af312bd 100644
--- a/spanner/transaction.go
+++ b/spanner/transaction.go
@@ -881,7 +881,7 @@
 		}
 		counts = append(counts, count)
 	}
-	if resp.Status.Code != 0 {
+	if resp.Status != nil && resp.Status.Code != 0 {
 		return counts, spannerErrorf(codes.Code(uint32(resp.Status.Code)), resp.Status.Message)
 	}
 	return counts, nil