acc: Fix priority of stubs in test.toml (#2339)

## Changes
Reverse the order of stubs to match expectation (leaf configuration
takes precedence over parent configuration).
Follow up to #2334 .

## Tests
acceptance/selftest/server is extended with duplicate handler
This commit is contained in:
Denis Bilenko 2025-02-12 12:45:01 +01:00 committed by GitHub
parent 24ac8d8d59
commit bfde3585b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 0 deletions

View File

@ -259,6 +259,10 @@ func runTest(t *testing.T, dir, coverDir string, repls testdiff.ReplacementsCont
server.RecordRequests = config.RecordRequests
server.IncludeRequestHeaders = config.IncludeRequestHeaders
// We want later stubs takes precedence, because then leaf configs take precedence over parent directory configs
// In gorilla/mux earlier handlers take precedence, so we need to reverse the order
slices.Reverse(config.Server)
for _, stub := range config.Server {
require.NotEmpty(t, stub.Pattern)
items := strings.Split(stub.Pattern, " ")

View File

@ -1,6 +1,10 @@
LocalOnly = true
RecordRequests = true
[[Server]]
Pattern = "GET /custom/endpoint"
Response.Body = '''should not see this response, latter response takes precedence'''
[[Server]]
Pattern = "GET /custom/endpoint"
Response.Body = '''custom