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

Multiple Providers #39

Closed
dgafka opened this issue Feb 13, 2016 · 9 comments
Closed

Multiple Providers #39

dgafka opened this issue Feb 13, 2016 · 9 comments

Comments

@dgafka
Copy link

dgafka commented Feb 13, 2016

The problem is about /pact DELETE. I have few tests within same consumer for multiple providers. When interactions for Provider A are finished I call DELETE on /pact and I would like to go with next Provider B. But when I do this I inherit Provider A interactions in pact file of Provider B, so for real they are not deleted.

Is there possibility to create pacts for multiple providers within one instance of pact-mock-service?

@bethesque
Copy link
Member

No, it's not designed to be used like this. I don't think there is a DELETE for /pact, only /interactions.

@dgafka
Copy link
Author

dgafka commented Feb 14, 2016

So is there any way to test multiple providers against one instance of pact-mock-service?

@sergei-matheson
Copy link
Contributor

You can run multiple pact mock service instances, specifying different ports for each with the --port option, with each instance representing a different provider. Multiple providers in a single running instance is not supported.

@dgafka
Copy link
Author

dgafka commented Feb 15, 2016

That's sad to hear.
Any future plans to make it work with more than one provider within the same instance?

There are two or more possibilities to do so.
First one. After creating pact, whole history could be deleted.
Second make possible to write interaction according to the provider name, which would be passed with interaction.

@sergei-matheson
Copy link
Contributor

There are, to the best of my knowledge, no plans to do so, as it would involve quite a bit of work, and potentially a modification to the pact file specification, which is shared by many implementations. Out of curiosity, is there a reason you can't just have a separate mock for each required provider?

@bethesque
Copy link
Member

If you give the consumer and provider names in the POST /pact call rather than at startup, it will use them to write the pact. Have a look at this code: https://github.com/bethesque/pact-mock_service/blob/master/lib/pact/mock_service/request_handlers/pact_post.rb

Actually, I've just come across DELETE /session - this might be what you're after, I'd forgotten about it because I didn't write it. https://github.com/bethesque/pact-mock_service/blob/master/lib/pact/mock_service/request_handlers/session_delete.rb

@dgafka
Copy link
Author

dgafka commented Feb 17, 2016

@bethesque thanks I was looking for such solution, but I found different one already. :)
I will implement docker image, which will be responsible for spawning multiple mock-services, so I will be able to run my tests without order. I guess It will simplify implementation of tests for developers in my company.

Anyway It's worth to add /session [DELETE] to github wiki.

@nathandeamer
Copy link

This is how I solved it using one pact-mock-service running on port 1234.

after each provider test:

  1. Write the current interactions to disk:
POST
http://localhost:1234/pact
X-Pact-Mock-Service: true
{"consumer": {"name": "CONSUMER"}, "provider": {"name": "PROVIDER"}}
  1. Clear the session:
DELETE
http://localhost:1234/session
X-Pact-Mock-Service: true

@YOU54F
Copy link
Member

YOU54F commented Aug 12, 2024

Closing as workaround provided, thanks

@YOU54F YOU54F closed this as completed Aug 12, 2024
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

No branches or pull requests

5 participants