forked from LeoYoung-code/utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsql_test.go
More file actions
43 lines (40 loc) · 905 Bytes
/
sql_test.go
File metadata and controls
43 lines (40 loc) · 905 Bytes
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
package utils
import (
"testing"
)
func Test_sqlInSliceInt64(t *testing.T) {
tests := []struct {
name string
opt string
field string
s []int64
want string
}{
{"11", "and", "aa", []int64{1, 2, 3}, " and `aa` IN (1,2,3)"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := SqlInSliceInt64(tt.opt, tt.field, tt.s); got != tt.want {
t.Errorf("SqlInSliceInt64() = %v, want %v", got, tt.want)
}
})
}
}
func Test_sqlInSliceString(t *testing.T) {
tests := []struct {
name string
opt string
field string
s []string
want string
}{
{"22", "and", "aa", []string{"1", "2", "3"}, " and `aa` IN ('1','2','3')"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := SqlInSliceString(tt.opt, tt.field, tt.s); got != tt.want {
t.Errorf("SqlInSliceInt64() = %v, want %v", got, tt.want)
}
})
}
}