Debian Codegraph @

nodes_info_test.go

raw
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
5 package elastic
6
7 import (
8 "context"
9 "testing"
10 )
11
12 func TestNodesInfo(t *testing.T) {
13 client, err := NewClient()
14 if err != nil {
15 t.Fatal(err)
16 }
17
18 info, err := client.NodesInfo().Do(context.TODO())
19 if err != nil {
20 t.Fatal(err)
21 }
22 if info == nil {
23 t.Fatal("expected nodes info")
24 }
25
26 if info.ClusterName == "" {
27 t.Errorf("expected cluster name; got: %q", info.ClusterName)
28 }
29 if len(info.Nodes) == 0 {
30 t.Errorf("expected some nodes; got: %d", len(info.Nodes))
31 }
32 for id, node := range info.Nodes {
33 if id == "" {
34 t.Errorf("expected node id; got: %q", id)
35 }
36 if node == nil {
37 t.Fatalf("expected node info; got: %v", node)
38 }
39 if node.IP == "" {
40 t.Errorf("expected node IP; got: %q", node.IP)
41 }
42 }
43 }