cat_count_test.go 745 B

12345678910111213141516171819202122232425262728
  1. // Copyright 2012-present Oliver Eilhard. All rights reserved.
  2. // Use of this source code is governed by a MIT-license.
  3. // See http://olivere.mit-license.org/license.txt for details.
  4. package elastic
  5. import (
  6. "context"
  7. "testing"
  8. )
  9. func TestCatCount(t *testing.T) {
  10. client := setupTestClientAndCreateIndexAndAddDocs(t, SetDecoder(&strictDecoder{})) // , SetTraceLog(log.New(os.Stdout, "", 0)))
  11. ctx := context.Background()
  12. res, err := client.CatCount().Pretty(true).Columns("*").Do(ctx)
  13. if err != nil {
  14. t.Fatal(err)
  15. }
  16. if res == nil {
  17. t.Fatal("want response, have nil")
  18. }
  19. if len(res) == 0 {
  20. t.Fatalf("want response, have: %v", res)
  21. }
  22. if have := res[0].Count; have <= 0 {
  23. t.Fatalf("Count[0]: want > %d, have %d", 0, have)
  24. }
  25. }