forked from defensestation/osquery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaggs_filter_test.go
46 lines (43 loc) · 1.08 KB
/
aggs_filter_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
// Modified by DefenseStation on 2024-06-06
// Changes: Updated ElasticSearch client to OpenSearch client, changed package name to 'osquery',
// updated references to OpenSearch documentation, and modified examples accordingly.
package osquery
import "testing"
func TestFilterAggs(t *testing.T) {
runMapTests(t, []mapTest{
{
"filter agg: simple",
FilterAgg("filtered", Term("type", "t-shirt")),
map[string]interface{}{
"filter": map[string]interface{}{
"term": map[string]interface{}{
"type": map[string]interface{}{
"value": "t-shirt",
},
},
},
},
},
{
"filter agg: with aggs",
FilterAgg("filtered", Term("type", "t-shirt")).
Aggs(Avg("avg_price", "price")),
map[string]interface{}{
"filter": map[string]interface{}{
"term": map[string]interface{}{
"type": map[string]interface{}{
"value": "t-shirt",
},
},
},
"aggs": map[string]interface{}{
"avg_price": map[string]interface{}{
"avg": map[string]interface{}{
"field": "price",
},
},
},
},
},
})
}