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

Function TestNew_MetaHeader

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

Source from the content-addressed store, hash-verified

362}
363
364func TestNew_MetaHeader(t *testing.T) {
365 t.Parallel()
366
367 c, err := New(
368 WithTransportOptions(
369 elastictransport.WithTransport(&mockTransp{
370 RoundTripFunc: func(req *http.Request) (*http.Response, error) {
371 h := req.Header.Get(HeaderClientMeta)
372 if !metaHeaderReValidation.MatchString(h) {
373 t.Errorf("expected meta header to match regexp, got: %s", h)
374 }
375 if strings.Contains(h, "hl=1") {
376 t.Errorf("low-level client should not have hl=1, got: %s", h)
377 }
378 return &http.Response{
379 StatusCode: http.StatusOK,
380 Header: http.Header{"X-Elastic-Product": []string{"Elasticsearch"}},
381 Body: io.NopCloser(strings.NewReader("{}")),
382 }, nil
383 },
384 }),
385 ),
386 )
387 if err != nil {
388 t.Fatalf("Unexpected error: %s", err)
389 }
390
391 _, err = c.Info()
392 if err != nil {
393 t.Fatalf("Unexpected error: %s", err)
394 }
395}
396
397func TestNewTyped_Default(t *testing.T) {
398 t.Setenv("ELASTICSEARCH_URL", "")

Callers

nothing calls this directly

Calls 4

WithTransportOptionsFunction · 0.85
NewFunction · 0.50
GetMethod · 0.45
InfoMethod · 0.45

Tested by

no test coverage detected