(t *testing.T)
| 362 | } |
| 363 | |
| 364 | func 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 | |
| 397 | func TestNewTyped_Default(t *testing.T) { |
| 398 | t.Setenv("ELASTICSEARCH_URL", "") |
nothing calls this directly
no test coverage detected