Skip to content

docs(examples): add a binary payloads example with matching rules - #1770

Open
YauheniPo wants to merge 1 commit into
pact-foundation:mainfrom
YauheniPo:feat/example-binary-payloads
Open

YauheniPo wants to merge 1 commit into
pact-foundation:mainfrom
YauheniPo:feat/example-binary-payloads

Conversation

@YauheniPo

Copy link
Copy Markdown

Binary bodies cannot carry matching rules inside them, so the contract has to constrain the payload as a whole. The example models a blob store and shows the contentType matcher on the body root for both directions:

  • test_consumer.py declares a binary request and a binary response with with_binary_body(), sends a payload whose length and contents differ from the contract example, and combines the binary request with a JSON response using match.int().
  • test_provider.py verifies a FastAPI implementation whose provider state seeds a payload that also differs from the contract example, so verification depends on the matching rule rather than on the example bytes.

Registered in examples/catalog/README.md. Closes #377.

✈️ Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

📝 Summary

🚨 Breaking Changes

🔥 Motivation

🔨 Test Plan

🔗 Related issues/PRs

Binary bodies cannot carry matching rules inside them, so the contract has to
constrain the payload as a whole. The example models a blob store and shows the
`contentType` matcher on the body root for both directions:

- `test_consumer.py` declares a binary request and a binary response with
  `with_binary_body()`, sends a payload whose length and contents differ from
  the contract example, and combines the binary request with a JSON response
  using `match.int()`.
- `test_provider.py` verifies a FastAPI implementation whose provider state
  seeds a payload that also differs from the contract example, so verification
  depends on the matching rule rather than on the example bytes.

Registered in `examples/catalog/README.md`. Closes pact-foundation#377.

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

Add a complete example with binary payloads

1 participant