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

Function TestNew_WithCompatibilityModeEnv

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

Source from the content-addressed store, hash-verified

298}
299
300func TestNew_WithCompatibilityModeEnv(t *testing.T) {
301 t.Setenv(esCompatHeader, "true")
302
303 c, err := New(
304 WithTransportOptions(
305 elastictransport.WithTransport(&mockTransp{
306 RoundTripFunc: func(_ *http.Request) (*http.Response, error) {
307 return &http.Response{
308 StatusCode: http.StatusOK,
309 Header: http.Header{"X-Elastic-Product": []string{"Elasticsearch"}},
310 Body: io.NopCloser(strings.NewReader("{}")),
311 }, nil
312 },
313 }),
314 ),
315 )
316 if err != nil {
317 t.Fatalf("Unexpected error: %s", err)
318 }
319
320 req := &http.Request{
321 URL: &url.URL{},
322 Header: make(http.Header),
323 Body: io.NopCloser(strings.NewReader("{}")),
324 }
325 _, err = c.Perform(req)
326 if err != nil {
327 t.Fatalf("Unexpected error: %s", err)
328 }
329}
330
331func TestNew_WithDisableMetaHeader(t *testing.T) {
332 t.Parallel()

Callers

nothing calls this directly

Calls 3

WithTransportOptionsFunction · 0.85
PerformMethod · 0.65
NewFunction · 0.50

Tested by

no test coverage detected