-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetter_test.go
53 lines (50 loc) · 1.14 KB
/
getter_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package dalgo2sql
import (
"github.com/dal-go/dalgo/dal"
"reflect"
"testing"
)
func Test_getSelectFields(t *testing.T) {
type args struct {
record dal.Record
includePK bool
options Options
}
tests := []struct {
name string
args args
wantFields []string
}{
{
name: "simple_fields_exclude_primary_key",
args: args{
record: dal.NewRecordWithIncompleteKey("SomeCollection", reflect.String, struct {
StrField string
IntField int
}{}),
includePK: false,
},
wantFields: []string{"StrField", "IntField"},
},
{
name: "simple_fields_include_primary_key",
args: args{
record: dal.NewRecordWithData(
dal.NewKeyWithID("TestTable", "r1"),
struct {
StrField string
IntField int
}{}),
includePK: true,
},
wantFields: []string{"ID", "StrField", "IntField"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if gotFields := getSelectFields(tt.args.includePK, tt.args.options, tt.args.record); !reflect.DeepEqual(gotFields, tt.wantFields) {
t.Errorf("getSelectFields() = %v, want %v", gotFields, tt.wantFields)
}
})
}
}