-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathclient_test.go
64 lines (53 loc) · 1.76 KB
/
client_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
57
58
59
60
61
62
63
64
package godruid
import (
"fmt"
. "github.com/smartystreets/goconvey/convey"
"testing"
)
func TestGroupby(t *testing.T) {
Convey("TestGroupby", t, func() {
query := &QueryGroupBy{
DataSource: "campaign",
Intervals: []string{"2014-09-01T00:00/2020-01-01T00"},
Granularity: GranAll,
Filter: FilterAnd(FilterJavaScript("hour", "function(x) { return(x >= 1) }"), nil),
LimitSpec: LimitDefault(5),
Dimensions: []DimSpec{"campaign_id"},
Aggregations: []Aggregation{AggRawJson(`{ "type" : "count", "name" : "count" }`), AggLongSum("impressions", "impressions")},
PostAggregations: []PostAggregation{PostAggArithmetic("imp/count", "/", []PostAggregation{
PostAggFieldAccessor("impressions"),
PostAggRawJson(`{ "type" : "fieldAccess", "fieldName" : "count" }`)})},
}
client := Client{
Url: "http://192.168.10.60:8009",
Debug: true,
}
err := client.Query(query)
fmt.Println("requst", client.LastRequest)
So(err, ShouldEqual, nil)
fmt.Println("response", client.LastResponse)
fmt.Printf("query.QueryResult:\n%v", query.QueryResult)
})
}
func TestSearch(t *testing.T) {
// return
Convey("TestSearch", t, func() {
query := &QuerySearch{
DataSource: "campaign",
Intervals: []string{"2014-09-01T00:00/2020-01-01T00"},
Granularity: GranAll,
SearchDimensions: []string{"campaign_id", "hour"},
Query: SearchQueryInsensitiveContains(1313),
Sort: SearchSortLexicographic,
}
client := Client{
Url: "http://192.168.10.60:8009",
Debug: true,
}
err := client.Query(query)
So(err, ShouldEqual, nil)
fmt.Println("requst", client.LastRequest)
fmt.Println("response", client.LastResponse)
fmt.Printf("query.QueryResult:\n%v", query.QueryResult)
})
}