How to set up an external host for a provider using pact python? #402
Replies: 1 comment
-
Before I answer, the best way to think of a Pact test is a unit test for your API client. Once you're in this frame of mind, things get a bit easier to understand. Unit tests are easier to reason about - because they are specific, targeted etc. - and give you more control over the test. Pact is a tool that is in contrast to techniques that involve testing live systems, because of the problems (see this series of videos for more on this).
In Pact tests (because they are unit tests), you need to isolate the provider. You should stub the downstream
Pact doesn't do this (although I think that would be nice to try). You need to send your requests to the pact mock service, which you have configured to run on port
|
Beta Was this translation helpful? Give feedback.
-
Hello, I need some help,
I am trying to build a contract test for 2 backend services
Here's a high level overview of how it works
Main backend interacts with a specific_data service
So my backend is the consumer and the specific_data_service is the provider
When I send a PUT request to the endpoint
/api/sepecific_data/{specific_uuid}/data
then the backend calls theupdate_specific_data()
functionThe
update_specific_data()
function then sends a PUT request to the external specific_data service which is hosted externally, the base url being something likehttps://specific-data-service.run.app/
My question is, how do I set up my provider url within the consumer test?
If I set it like
Then when I run
The request isn't actualy being intercepted and tries to call the actual external API
Is there a way to set my provider like?
❓
Sorry for the super long text
I really hope someone can help me 🙏
Beta Was this translation helpful? Give feedback.
All reactions