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

Expecting null message body #1637

Open
dominikbrandon opened this issue Nov 15, 2022 · 2 comments
Open

Expecting null message body #1637

dominikbrandon opened this issue Nov 15, 2022 · 2 comments

Comments

@dominikbrandon
Copy link

Hi, I'm using Pact as a consumer in order to test events being sent by the provider. Tests are written in Groovy. This particular use case looks like this: when an entity gets created, an event is sent to Kafka, having some properties in the body and a particular key corresponding to the entity's id. When an entity gets deleted, an event is sent to Kafka, having the same key, but a null body.

How do I ensure that the provider will send the message with a null body? Is it even possible? I've tried multiple different options with the basic one looking like below, but matchingRules in the resulting JSON are always missing. I may be missing something, but I haven't yet found a way how to make it work.

return new PactMessageBuilder().call {
    ...
    withContent(contentType: "application/json") {
        null
    }
}
@rholshausen
Copy link
Contributor

When you mean message with a null body, is that a body that contains a JSON NULL value, or that there is no body at all?

@dominikbrandon
Copy link
Author

I meant no body at all. Sorry for being unclear.

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

3 participants