query_test.go
1.2 KB
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
61
62
63
64
65
66
package starrocks
import (
"github.com/stretchr/testify/assert"
"testing"
"time"
)
func TestInArgs(t *testing.T) {
now := time.Date(2000, 1, 1, 0, 0, 0, 0, time.Local)
var table = []struct {
args []interface{}
want string
}{
{
args: []interface{}{1, 0, 2, 4},
want: "(1,0,2,4)",
},
{
args: []interface{}{1.0, 0, 2.1, 4.0},
want: "(1,0,2.1,4)",
},
{
args: []interface{}{"1", "0", "2", "4"},
want: "('1','0','2','4')",
},
{
args: []interface{}{now, now},
want: "('2000-01-01 00:00:00','2000-01-01 00:00:00')",
},
}
c := &Condition{}
for _, input := range table {
got := c.InArgs(input.args)
assert.Equal(t, input.want, got)
}
}
func TestArg(t *testing.T) {
now := time.Date(2000, 1, 1, 0, 0, 0, 0, time.Local)
var table = []struct {
args []interface{}
want string
}{
{
args: []interface{}{1, 0, 2, 4},
want: "1",
},
{
args: []interface{}{1.0, 0, 2.1, 4.0},
want: "1",
},
{
args: []interface{}{"1", "0", "2", "4"},
want: "'1'",
},
{
args: []interface{}{now, now},
want: "'2000-01-01 00:00:00'",
},
}
c := &Condition{}
for _, input := range table {
got := c.Arg(input.args[0])
assert.Equal(t, input.want, got)
}
}