Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(spanner): fix the failed TestColumnTypeErr test #4450

Merged
merged 3 commits into from Jul 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion spanner/row_test.go
Expand Up @@ -18,6 +18,7 @@ package spanner

import (
"encoding/base64"
"fmt"
"reflect"
"strconv"
"strings"
Expand Down Expand Up @@ -417,6 +418,9 @@ func TestColumnTypeErr(t *testing.T) {
etc = f.Type.ArrayElementType.Code
}
wantErr := errDecodeColumn(i, errTypeMismatch(tc, etc, badDst))
if strings.Contains(f.Name, "STRUCT_ARRAY") {
wantErr = errDecodeColumn(i, fmt.Errorf("the container is not a slice of struct pointers: %v", errTypeMismatch(tc, etc, badDst)))
}
if gotErr := row.Column(i, badDst); !testEqual(gotErr, wantErr) {
t.Errorf("Column(%v): decoding into destination with wrong type %T returns error %v, want %v",
i, badDst, gotErr, wantErr)
Expand Down Expand Up @@ -1685,7 +1689,11 @@ func TestRowToString(t *testing.T) {
}
got := r.String()
want := `{fields: [name:"F1" type:{code:STRING} name:"F2" type:{code:STRING}], values: [string_value:"v1" string_value:"v2"]}`
if !testEqual(r.String(), want) {
// In protobuf-go, the encoder will add an additional space based on a
// deterministically random boolean value.
wantWithTwoSpaces := `{fields: [name:"F1" type:{code:STRING} name:"F2" type:{code:STRING}], values: [string_value:"v1" string_value:"v2"]}`

if !testEqual(r.String(), want) && !testEqual(r.String(), wantWithTwoSpaces) {
t.Errorf("got %+v, want %+v", got, want)
}
}
Expand Down