cat_health_test.go 741 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 TestCatHealth(t *testing.T) {
  10. client := setupTestClientAndCreateIndexAndAddDocs(t, SetDecoder(&strictDecoder{})) // , SetTraceLog(log.New(os.Stdout, "", 0)))
  11. ctx := context.Background()
  12. res, err := client.CatHealth().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].Cluster; have == "" {
  23. t.Fatalf("Cluster[0]: want != %q, have %q", "", have)
  24. }
  25. }