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

docs(examples a->b->c): starting point of implementing Pact tests where there is a chain of services #276

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mikegeeves
Copy link
Contributor

No description provided.

@mefellows
Copy link
Member

Wow, this is a big one. I'll pop it on the TODO - but thank you for doing this 🙏

success, logs = verifier.verify_with_broker(
**broker_opts,
verbose=True,
provider_states_setup_url=f"{PROVIDER_URL}/_pact/provider_states",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to understand provider_states_setup_url, can you explain what it does or point me to documentation about it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't manage to find as good documentation as I would like for that when I was trying to get it working, descriptions and examples in some languages but it probably needs more work. https://docs.pact.io/implementation_guides/python/readme#provider-states

The TLDR is you create an extra endpoint (created here: examples/abc/provider_b_hub/tests/pact_provider_b.py). When the verifier performs the tests, for each test it FIRST does a POST to that endpoint with {"state": "some books exist"} etc. You then define whatever you need to there to get the service into an appropriate state, so when the ACTUAL request is made, it can behave as desired.

I like how this is setup with FastAPI, to be able to only have this extra route for the purposes of testing, it gives a nice way to not have some super admin drop all tables and setup endpoint accidentally left open!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revisiting this, I think I can do something similar in Django. This is intriguing. Thanks!

@YOU54F
Copy link
Member

YOU54F commented Apr 25, 2022

@mikegeeves nice work fella, will have a review this week

@YOU54F YOU54F self-requested a review April 25, 2022 09:55
@mikegeeves
Copy link
Contributor Author

There's a long thread somewhere on this, I think it needs some re-work to shuffle around where Pact is wrapping around. Currently I'm mocking the http call, but from a long discussion with Tim it sounds like it would be better to move this up so it's wrapping a method around it rather than that low level. How to mock the http call like that is nice to know how to [fun figuring out getting that working :D] but I think higher up makes sense to then have a nicer pattern for the next step of async rather than HTTP where the pattern can be continued rather than completely different

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.

4 participants