DiUS / pact-consumer-js-dsl

*DEPRECATED* A Javascript DSL for creating pacts, superceded by Pact JS
https://github.com/pact-foundation/pact-js
Other
56 stars 26 forks source link

Interactions are put into the wrong pact file #43

Closed BenSayers closed 8 years ago

BenSayers commented 8 years ago

I suspect this is a bug in the pact mock service, but I'll raise it here since this is how I'm consuming it. I am running the latest versions of this library as well as the pact mock service.

I have a single test run which contains pact tests for multiple providers (lets call the providers Provider A and Provider B). As expected when the tests finish running there are two pact files generated, one for each provider. The test runner executes Provider A's pact tests first, then Provider B's.

What I am finding is that the pact file for Provider B has the interactions for Provider A within it in addition to the interactions for Provider B. When I comment out the tests for Provider A the issue stops - which gives me confidence I have not made a silly mistake. The generated pact file for Provider A has the correct interactions within it.

bethesque commented 8 years ago

Are you running two separate instances of the mock service?

BenSayers commented 8 years ago

I'm running a single instance of the ruby pact mock service. In my JavaScript tests I created two separate instances of the pact mock service, giving them the correct consumer and provider names, but pointing to the same ruby pact mock service. I was expecting this to work as I have provided enough information for the interactions to be associated with the right provider. Is this where I have gone wrong?

bethesque commented 8 years ago

You need to run two separate mock service services, you can't use the same one.

BenSayers commented 8 years ago

I can confirm that using two separate instances of the ruby pact mock service fixes the issue. I can live with this, but it did come as a surprise to me that a single instance cannot handle multiple providers. Whats the thinking behind preventing a single instance from handling multiple providers?

bethesque commented 8 years ago

It would get confused - there's nothing in the actual requests that come through that would tell it which interaction set to look in to find the expected interactions.

BenSayers commented 8 years ago

I'm assuming the use case where the confusion occurs is in a single test that involves multiple interactions across many providers?

bethesque commented 8 years ago

Yes.