Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

header method in V4 PactBuilder splits up values #1852

Open
huehnerlady opened this issue Jan 17, 2025 · 0 comments
Open

header method in V4 PactBuilder splits up values #1852

huehnerlady opened this issue Jan 17, 2025 · 0 comments

Comments

@huehnerlady
Copy link
Contributor

Hi,
I am currently trying to move to V4 pacts.

Currently I have this pact, which works

@Pact(consumer = CONSUMER, provider = PROVIDER)
RequestResponsePact provider(PactDslWithProvider builder) {
  return builder
      .uponReceiving("get")
      .method("GET")
      .headers("accept", "application/json, application/*+json")
      .path("/test")
      .willRespondWith()
      .status(200)
      .toPact()
}

I migrated it to look like this:

@Pact(consumer = CONSUMER, provider = PROVIDER)
V4Pact provider(PactBuilder builder) {
  return builder
      .expectsToReceiveHttpInteraction("get") { httpBuilder ->
        httpBuilder
            .withRequest { httpRequestBuilder ->
              httpRequestBuilder
                  .path("/test")
                  .method("GET")
                  .headers("accept", "application/json, application/*+json")
            }
            .willRespondWith { httpResponseBuilder ->
              httpResponseBuilder.status(200)
            }
      }
      .toPact()
}

but now I get this error message from Pact:

2025-01-16 11:41:50,475 [HTTP-Dispatcher] ERROR  a.c.d.p.c.BaseMockServer$Companion - PartialRequestMatch: get:
    Expected header 'accept' to have value 'application/json' but was 'application/json, application/*+json'
    Expected header 'accept' to have value 'application/*+json' but was ''

I am very confused as the signature of the method headers I am using shows it as a value:String. I also tried the header method, but I still get the same error.

After asking in Slack what I can do I was asked to raise it as a potential bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant