@@ -2008,6 +2008,12 @@ func TestSelectAll(t *testing.T) {
2008
2008
Col3 string
2009
2009
Col4 time.Time
2010
2010
}
2011
+ type testStructWithTag struct {
2012
+ Col1 int64 `spanner:"tag1"`
2013
+ Col2 float64 `spanner:"Tag2"`
2014
+ Col3 string `spanner:"taG3"`
2015
+ Col4 time.Time `spanner:"TAG4"`
2016
+ }
2011
2017
tests := []struct {
2012
2018
name string
2013
2019
args args
@@ -2175,7 +2181,40 @@ func TestSelectAll(t *testing.T) {
2175
2181
{Col1 : 3 , COL2 : 3.3 , Col3 : "value3" },
2176
2182
{Col1 : 1 , COL2 : 1.1 , Col3 : "value" },
2177
2183
{Col1 : 2 , COL2 : 2.2 , Col3 : "value2" },
2178
- }},
2184
+ },
2185
+ },
2186
+ {
2187
+ name : "success: using slice of structs with spanner tag annotations" ,
2188
+ args : args {
2189
+ destination : & []testStructWithTag {},
2190
+ mock : func (mockIterator * mockRowIterator ) {
2191
+ mockIterator .On ("Next" ).Once ().Return (& Row {
2192
+ []* sppb.StructType_Field {
2193
+ {Name : "Tag1" , Type : intType ()},
2194
+ {Name : "Tag2" , Type : floatType ()},
2195
+ {Name : "Tag3" , Type : stringType ()},
2196
+ {Name : "Tag4" , Type : timeType ()},
2197
+ },
2198
+ []* proto3.Value {intProto (1 ), floatProto (1.1 ), stringProto ("value" ), timeProto (tm )},
2199
+ }, nil )
2200
+ mockIterator .On ("Next" ).Once ().Return (& Row {
2201
+ []* sppb.StructType_Field {
2202
+ {Name : "Tag1" , Type : intType ()},
2203
+ {Name : "Tag2" , Type : floatType ()},
2204
+ {Name : "Tag3" , Type : stringType ()},
2205
+ {Name : "Tag4" , Type : timeType ()},
2206
+ },
2207
+ []* proto3.Value {intProto (2 ), floatProto (2.2 ), stringProto ("value2" ), timeProto (tm .Add (24 * time .Hour ))},
2208
+ }, nil )
2209
+ mockIterator .On ("Next" ).Once ().Return (nil , iterator .Done )
2210
+ mockIterator .On ("Stop" ).Once ().Return (nil )
2211
+ },
2212
+ },
2213
+ want : & []testStructWithTag {
2214
+ {Col1 : 1 , Col2 : 1.1 , Col3 : "value" , Col4 : tm },
2215
+ {Col1 : 2 , Col2 : 2.2 , Col3 : "value2" , Col4 : tm .Add (24 * time .Hour )},
2216
+ },
2217
+ },
2179
2218
{
2180
2219
name : "failure: in case of error destination will have the partial result" ,
2181
2220
args : args {
0 commit comments