forked from chuckpreslar/codex
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction_test.go
More file actions
68 lines (54 loc) · 1.49 KB
/
function_test.go
File metadata and controls
68 lines (54 loc) · 1.49 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
67
68
package codex
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestFunction(t *testing.T) {
f := Function("TEST_FUNC", 1, 2, 3, 4)
// The following struct members should exist.
assert.Equal(t, "TEST_FUNC", f.Name)
assert.Equal(t, []interface{}{1, 2, 3, 4}, f.Args)
assert.Nil(t, f.Alias)
assert.False(t, f.Distinct)
// The following receiver methods should exist.
_ = f.And(1)
_ = f.Or(1)
_ = f.Eq(1)
_ = f.Neq(1)
_ = f.Gt(1)
_ = f.Gte(1)
_ = f.Lt(1)
_ = f.Lte(1)
_ = f.Like(1)
_ = f.Unlike(1)
_ = f.As("foo")
}
func TestFunctions(t *testing.T) {
f := Avg(1, 2, 3)
assert.Equal(t, "AVG", f.Name)
assert.Equal(t, []interface{}{1, 2, 3}, f.Args)
f = Coalesce(1, 2, 3)
assert.Equal(t, "COALESCE", f.Name)
assert.Equal(t, []interface{}{1, 2, 3}, f.Args)
f = Count(1, 2, 3)
assert.Equal(t, "COUNT", f.Name)
assert.Equal(t, []interface{}{1, 2, 3}, f.Args)
f = Max(1, 2, 3)
assert.Equal(t, "MAX", f.Name)
assert.Equal(t, []interface{}{1, 2, 3}, f.Args)
f = Min(1, 2, 3)
assert.Equal(t, "MIN", f.Name)
assert.Equal(t, []interface{}{1, 2, 3}, f.Args)
f = Sum(1, 2, 3)
assert.Equal(t, "SUM", f.Name)
assert.Equal(t, []interface{}{1, 2, 3}, f.Args)
f = Lower(1, 2, 3)
assert.Equal(t, "LOWER", f.Name)
assert.Equal(t, []interface{}{1, 2, 3}, f.Args)
f = Upper(1, 2, 3)
assert.Equal(t, "UPPER", f.Name)
assert.Equal(t, []interface{}{1, 2, 3}, f.Args)
f = Substring(1, 2, 3)
assert.Equal(t, "SUBSTRING", f.Name)
assert.Equal(t, []interface{}{1, 2, 3}, f.Args)
}