MCPcopy
hub / github.com/elastic/go-elasticsearch / TestNew_WithMultipleAddresses

Function TestNew_WithMultipleAddresses

options_test.go:59–75  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

57}
58
59func TestNew_WithMultipleAddresses(t *testing.T) {
60 t.Parallel()
61 c, err := New(WithAddresses("http://es01:9200", "http://es02:9200"))
62 if err != nil {
63 t.Fatalf("Unexpected error: %s", err)
64 }
65 urls := c.Transport.(*elastictransport.Client).URLs()
66 if len(urls) != 2 {
67 t.Fatalf("Expected 2 URLs, got %d", len(urls))
68 }
69 if urls[0].String() != "http://es01:9200" {
70 t.Errorf("Unexpected URL[0], want=http://es01:9200, got=%s", urls[0])
71 }
72 if urls[1].String() != "http://es02:9200" {
73 t.Errorf("Unexpected URL[1], want=http://es02:9200, got=%s", urls[1])
74 }
75}
76
77func TestNew_WithAddressesFromEnvironment(t *testing.T) {
78 t.Setenv("ELASTICSEARCH_URL", "http://example.com")

Callers

nothing calls this directly

Calls 3

WithAddressesFunction · 0.85
NewFunction · 0.50
StringMethod · 0.45

Tested by

no test coverage detected