-
Notifications
You must be signed in to change notification settings - Fork 4
/
CloudQuery_test.go
56 lines (50 loc) · 1.16 KB
/
CloudQuery_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
package lean
import (
"os"
"testing"
)
//any better way?
type TestResp struct {
Results []Test `json:"results,omitempty"`
Count int64 `json:"count,omitempty"`
}
func TestCloudQuery(t *testing.T) {
client := NewClient(os.Getenv("LEAN_APPID"),
os.Getenv("LEAN_APPKEY"),
os.Getenv("LEAN_MASTERKEY"))
agent := client.CloudQuery("select * from test")
agent.Do()
ret := TestResp{}
agent.ScanResponse(&ret)
if len(ret.Results) == 0 {
t.Error("cloud query failed")
return
}
if ret.Results[0].Hello == "" {
t.Error("cloud query can not get value")
return
}
}
func TestCloudQueryWithValue(t *testing.T) {
client := NewClient(os.Getenv("LEAN_APPID"),
os.Getenv("LEAN_APPKEY"),
os.Getenv("LEAN_MASTERKEY"))
agent := client.CloudQuery("select * from test where hi != ?", "hello")
if err := agent.Do(); nil != err {
t.Log(agent.superAgent.QueryData)
t.Error(err.Error())
return
}
ret := TestResp{}
agent.ScanResponse(&ret)
if len(ret.Results) == 0 {
t.Log(agent.superAgent.Data)
t.Error("cloud query failed")
return
}
if ret.Results[0].Hello == "" {
t.Error("cloud query can not get value")
return
}
t.Log(agent.superAgent.QueryData)
}