-
Notifications
You must be signed in to change notification settings - Fork 137
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
base: master
Are you sure you want to change the base?
Conversation
…re there is a chain of services
…re there is a chain of services
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", |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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!
@mikegeeves nice work fella, will have a review this week |
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 |
No description provided.