TestSkipASTTransformationsMerge verifies that the per-request skip_ast_transformations URL parameter is merged with the global config list rather than overwritten by it.
(t *testing.T)
| 1411 | // TestSkipASTTransformationsMerge verifies that the per-request skip_ast_transformations |
| 1412 | // URL parameter is merged with the global config list rather than overwritten by it. |
| 1413 | func TestSkipASTTransformationsMerge(t *testing.T) { |
| 1414 | tests := []struct { |
| 1415 | name string |
| 1416 | globalSkip []string |
| 1417 | requestSkip string // URL param value; empty means param is absent |
| 1418 | expectedSkip []string |
| 1419 | }{ |
| 1420 | { |
| 1421 | name: "global config only", |
| 1422 | globalSkip: []string{"global_skip"}, |
| 1423 | requestSkip: "", |
| 1424 | expectedSkip: []string{"global_skip"}, |
| 1425 | }, |
| 1426 | { |
| 1427 | name: "per-request only", |
| 1428 | globalSkip: nil, |
| 1429 | requestSkip: "per_req_skip", |
| 1430 | expectedSkip: []string{"per_req_skip"}, |
| 1431 | }, |
| 1432 | { |
| 1433 | name: "merge global and per-request", |
| 1434 | globalSkip: []string{"global_skip"}, |
| 1435 | requestSkip: "per_req_skip", |
| 1436 | expectedSkip: []string{"global_skip", "per_req_skip"}, |
| 1437 | }, |
| 1438 | { |
| 1439 | name: "duplicated entries", |
| 1440 | globalSkip: []string{"or_to_in"}, |
| 1441 | requestSkip: "or_to_in", |
| 1442 | expectedSkip: []string{"or_to_in"}, |
| 1443 | }, |
| 1444 | { |
| 1445 | name: "neither", |
| 1446 | globalSkip: nil, |
| 1447 | requestSkip: "", |
| 1448 | expectedSkip: nil, |
| 1449 | }, |
| 1450 | } |
| 1451 | |
| 1452 | for _, tc := range tests { |
| 1453 | t.Run(tc.name, func(t *testing.T) { |
| 1454 | var capturedSkip []string |
| 1455 | |
| 1456 | next := pipeline.AsyncRoundTripperFunc[combiner.PipelineResponse](func(r pipeline.Request) (pipeline.Responses[combiner.PipelineResponse], error) { |
| 1457 | req, err := api.ParseSearchRequest(r.HTTPRequest()) |
| 1458 | if err == nil { |
| 1459 | capturedSkip = req.SkipASTTransformations |
| 1460 | } |
| 1461 | return pipeline.NewAsyncResponse(nil), nil |
| 1462 | }) |
| 1463 | |
| 1464 | o, err := overrides.NewOverrides(overrides.Config{}, nil, prometheus.DefaultRegisterer) |
| 1465 | require.NoError(t, err) |
| 1466 | |
| 1467 | sharder := newAsyncSearchSharder(&mockReader{}, o, SearchSharderConfig{ |
| 1468 | ConcurrentRequests: defaultConcurrentRequests, |
| 1469 | TargetBytesPerRequest: defaultTargetBytesPerRequest, |
| 1470 | }, tc.globalSkip, newJobsPerQueryHistogram(), log.NewNopLogger()) |
nothing calls this directly
no test coverage detected