-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpartiql_functions_test.go
60 lines (58 loc) · 1.04 KB
/
partiql_functions_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
54
55
56
57
58
59
60
package dynmgrm
import (
"errors"
"github.com/google/go-cmp/cmp"
"gorm.io/gorm"
"testing"
)
func Test_listAppend_expression(t *testing.T) {
type args struct {
db *gorm.DB
column string
}
type want struct {
xp string
err error
}
type test struct {
args args
want want
}
tests := map[string]test{
"happy_path": {
args: args{
db: &gorm.DB{
Config: &gorm.Config{},
},
column: "A",
},
want: want{
xp: "list_append(A, ",
},
},
"unhappy_path": {
args: args{
db: &gorm.DB{
Config: &gorm.Config{},
},
column: "A==true",
},
want: want{
err: ErrInvalidColumnName,
},
},
}
for name, tt := range tests {
t.Run(name, func(t *testing.T) {
la := ListAppend()
got := la.expression(tt.args.db, tt.args.column)
err := tt.args.db.Error
if !errors.Is(err, tt.want.err) {
t.Errorf("expression() error = %v, want nil", err)
}
if diff := cmp.Diff(tt.want.xp, got); diff != "" {
t.Errorf("expression() mismatch (-want +got):\n%s", diff)
}
})
}
}