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

feat(spanner): SelectAll struct spanner tag annotation match should be case-insensitive #9460

Merged
merged 2 commits into from
Feb 23, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
feat(spanner): Add a test case (#9460)
  • Loading branch information
yukia3e committed Feb 23, 2024
commit 0ad0aeeef6dbebe7e8ed12626d815588b4ffb42b
41 changes: 40 additions & 1 deletion spanner/row_test.go
Expand Up @@ -2008,6 +2008,12 @@ func TestSelectAll(t *testing.T) {
Col3 string
Col4 time.Time
}
type testStructWithTag struct {
Col1 int64 `spanner:"tag1"`
Col2 float64 `spanner:"Tag2"`
Col3 string `spanner:"taG3"`
Col4 time.Time `spanner:"TAG4"`
}
tests := []struct {
name string
args args
Expand Down Expand Up @@ -2175,7 +2181,40 @@ func TestSelectAll(t *testing.T) {
{Col1: 3, COL2: 3.3, Col3: "value3"},
{Col1: 1, COL2: 1.1, Col3: "value"},
{Col1: 2, COL2: 2.2, Col3: "value2"},
}},
},
},
{
name: "success: using slice of structs with spanner tag annotations",
args: args{
destination: &[]testStructWithTag{},
mock: func(mockIterator *mockRowIterator) {
mockIterator.On("Next").Once().Return(&Row{
[]*sppb.StructType_Field{
{Name: "Tag1", Type: intType()},
{Name: "Tag2", Type: floatType()},
{Name: "Tag3", Type: stringType()},
{Name: "Tag4", Type: timeType()},
},
[]*proto3.Value{intProto(1), floatProto(1.1), stringProto("value"), timeProto(tm)},
}, nil)
mockIterator.On("Next").Once().Return(&Row{
[]*sppb.StructType_Field{
{Name: "Tag1", Type: intType()},
{Name: "Tag2", Type: floatType()},
{Name: "Tag3", Type: stringType()},
{Name: "Tag4", Type: timeType()},
},
[]*proto3.Value{intProto(2), floatProto(2.2), stringProto("value2"), timeProto(tm.Add(24 * time.Hour))},
}, nil)
mockIterator.On("Next").Once().Return(nil, iterator.Done)
mockIterator.On("Stop").Once().Return(nil)
},
},
want: &[]testStructWithTag{
{Col1: 1, Col2: 1.1, Col3: "value", Col4: tm},
{Col1: 2, Col2: 2.2, Col3: "value2", Col4: tm.Add(24 * time.Hour)},
},
},
{
name: "failure: in case of error destination will have the partial result",
args: args{
Expand Down