(t *testing.T)
| 257 | } |
| 258 | |
| 259 | func TestNew_WithCompatibilityMode(t *testing.T) { |
| 260 | t.Parallel() |
| 261 | |
| 262 | var capturedReq *http.Request |
| 263 | c, err := New( |
| 264 | WithCompatibilityMode(), |
| 265 | WithTransportOptions( |
| 266 | elastictransport.WithTransport(&mockTransp{ |
| 267 | RoundTripFunc: func(req *http.Request) (*http.Response, error) { |
| 268 | capturedReq = req |
| 269 | return &http.Response{ |
| 270 | StatusCode: http.StatusOK, |
| 271 | Header: http.Header{"X-Elastic-Product": []string{"Elasticsearch"}}, |
| 272 | Body: io.NopCloser(strings.NewReader("{}")), |
| 273 | }, nil |
| 274 | }, |
| 275 | }), |
| 276 | ), |
| 277 | ) |
| 278 | if err != nil { |
| 279 | t.Fatalf("Unexpected error: %s", err) |
| 280 | } |
| 281 | |
| 282 | req := &http.Request{ |
| 283 | URL: &url.URL{}, |
| 284 | Header: make(http.Header), |
| 285 | Body: io.NopCloser(strings.NewReader("{}")), |
| 286 | } |
| 287 | _, err = c.Perform(req) |
| 288 | if err != nil { |
| 289 | t.Fatalf("Unexpected error: %s", err) |
| 290 | } |
| 291 | |
| 292 | if capturedReq.Header.Get("Accept") != compatibilityHeader { |
| 293 | t.Errorf("Expected compatibility Accept header, got: %s", capturedReq.Header.Get("Accept")) |
| 294 | } |
| 295 | if capturedReq.Header.Get("Content-Type") != compatibilityHeader { |
| 296 | t.Errorf("Expected compatibility Content-Type header, got: %s", capturedReq.Header.Get("Content-Type")) |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | func TestNew_WithCompatibilityModeEnv(t *testing.T) { |
| 301 | t.Setenv(esCompatHeader, "true") |
nothing calls this directly
no test coverage detected