Unified Storage: in SQL template, also handle output data, improve API, examples and docs (#87560)
* preview of work so far * stylistic improvements * fix linters * remove golden tests, they may cause the system to be too rigid to changes * remove unnecessary code for golden tests * remove white space mangling in Execute * also handle output data, improve API, examples and docs * add helper methods * fix interface
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package sqltemplate
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestScanDest_Into(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var d ScanDest
|
||||
|
||||
colName, err := d.Into(reflect.Value{}, "some field")
|
||||
if colName != "" || err == nil || len(d.GetScanDest()) != 0 {
|
||||
t.Fatalf("unexpected outcome, got colname %q, err: %v, scan dest: %#v",
|
||||
colName, err, d)
|
||||
}
|
||||
|
||||
data := struct {
|
||||
X int
|
||||
Y byte
|
||||
}{}
|
||||
dataVal := reflect.ValueOf(&data).Elem()
|
||||
|
||||
colName, err = d.Into(dataVal.FieldByName("X"), "some int")
|
||||
if err != nil || colName != "some int" || len(d) != 1 || d[0] != &data.X {
|
||||
t.Fatalf("unexpected outcome, got colname %q, err: %v, scan dest: %#v",
|
||||
colName, err, d)
|
||||
}
|
||||
|
||||
colName, err = d.Into(dataVal.FieldByName("Y"), "some byte")
|
||||
if err != nil || colName != "some byte" || len(d) != 2 || d[1] != &data.Y {
|
||||
t.Fatalf("unexpected outcome, got colname %q, err: %v, scan dest: %#v",
|
||||
colName, err, d)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user