forked from olivere/elastic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cat_count_integration_test.go
44 lines (36 loc) · 1010 Bytes
/
cat_count_integration_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
// Copyright 2012-present Oliver Eilhard. All rights reserved.
// Use of this source code is governed by a MIT-license.
// See http://olivere.mit-license.org/license.txt for details.
package elastic
import (
"context"
"testing"
)
func TestCatCountIntegration(t *testing.T) {
client := setupTestClientAndCreateIndexAndAddDocs(t) //, SetTraceLog(log.New(os.Stdout, "", 0)))
var (
total int64
indices = []string{testIndexName, testIndexName2, testOrderIndex}
)
for _, index := range indices {
count, err := client.Count(index).Do(context.Background())
if err != nil {
t.Fatal(err)
}
total += count
}
resp, err := client.CatCount().
Index(indices...).
Columns("*").
Pretty(true).
Do(context.Background())
if err != nil {
t.Fatal(err)
}
if want, have := 1, len(resp); want != have {
t.Fatalf("expected %d response item, got %d", want, have)
}
if want, have := total, int64(resp[0].Count); want != have {
t.Fatalf("expected %d documents, got %d", want, have)
}
}