forked from aquasecurity/esquery
-
Notifications
You must be signed in to change notification settings - Fork 1
/
custom_test.go
55 lines (50 loc) · 946 Bytes
/
custom_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
package osquery
import "testing"
func TestCustomQuery(t *testing.T) {
m := map[string]interface{}{
"geo_distance": map[string]interface{}{
"distance": "200km",
"pin.location": map[string]interface{}{
"lat": 40,
"lon": -70,
},
},
}
runMapTests(t, []mapTest{
{
"custom query",
CustomQuery(m),
m,
},
})
}
func TestCustomAgg(t *testing.T) {
m := map[string]interface{}{
"genres": map[string]interface{}{
"terms": map[string]interface{}{
"field": "genre",
},
"t_shirts": map[string]interface{}{
"filter": map[string]interface{}{
"term": map[string]interface{}{
"type": "t-shirt",
},
},
"aggs": map[string]interface{}{
"avg_price": map[string]interface{}{
"avg": map[string]interface{}{
"field": "price",
},
},
},
},
},
}
runMapTests(t, []mapTest{
{
"custom aggregation",
CustomAgg("custom_agg", m),
m,
},
})
}