forked from vesoft-inc/nebula-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil_test.go
29 lines (24 loc) · 888 Bytes
/
util_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
package nebula_go
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestUtil_IndexOf(t *testing.T) {
collection := []string{"a", "b", "c"}
assert.Equal(t, IndexOf(collection, "a"), 0)
assert.Equal(t, IndexOf(collection, "b"), 1)
assert.Equal(t, IndexOf(collection, "c"), 2)
assert.Equal(t, IndexOf(collection, "d"), -1)
}
func TestUtil_parseTTL(t *testing.T) {
s := "CREATE TAG `user` (\n\t\t`name` string NOT NULL,\n\t\t`created_at` int64 NULL\n\t) ttl_duration = 5, ttl_col = \"created_at\""
col, duration, err := parseTTL(s)
assert.Nil(t, err)
assert.Equal(t, col, "created_at")
assert.Equal(t, duration, uint(5))
s = "CREATE TAG `user` (\n\t\t`name` string NOT NULL,\n\t\t`created_at` int64 NULL\n\t) ttl_duration = 0, ttl_col = \"\""
col, duration, err = parseTTL(s)
assert.Nil(t, err)
assert.Equal(t, col, "")
assert.Equal(t, duration, uint(0))
}