-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added support for message provider using pact broker (#257)
* feat: added support for message provider using pact broker * fix: added new line * fix: update tests to support pact-broker runs fix: updated message_pact to wait writing contract process to finish * fix: removed time from import
- Loading branch information
Showing
12 changed files
with
206 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
|
||
from testcontainers.compose import DockerCompose | ||
|
||
import pytest | ||
|
||
|
||
def pytest_addoption(parser): | ||
parser.addoption( | ||
"--publish-pact", type=str, action="store", | ||
help="Upload generated pact file to pact broker with version" | ||
) | ||
|
||
parser.addoption( | ||
"--provider-url", type=str, action="store", | ||
help="The url to our provider." | ||
) | ||
|
||
parser.addoption( | ||
"--run-broker", type=bool, action="store", | ||
help="Whether to run broker in this test or not." | ||
) | ||
|
||
|
||
# This fixture is to simulate a managed Pact Broker or Pactflow account | ||
# Do not do this yourself but setup one of the above | ||
# https://github.com/pact-foundation/pact_broker | ||
@pytest.fixture(scope='session', autouse=True) | ||
def broker(request): | ||
version = request.config.getoption('--publish-pact') | ||
publish = True if version else False | ||
|
||
# yield | ||
if not publish: | ||
yield | ||
return | ||
|
||
run_broker = request.config.getoption('--run-broker') | ||
|
||
if not run_broker: | ||
yield | ||
return | ||
else: | ||
print('Starting broker') | ||
with DockerCompose("../broker", | ||
compose_file_name=["docker-compose.yml"], | ||
pull=True) as compose: | ||
|
||
stdout, stderr = compose.get_logs() | ||
if stderr: | ||
print("Errors\\n:{}".format(stderr)) | ||
print(stdout) | ||
yield |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/bin/bash | ||
set -o pipefail | ||
|
||
pytest | ||
pytest --run-broker True --publish-pact 2 | ||
|
||
# publish to broker assuming broker is active | ||
# pytest tests/consumer/test_message_consumer.py::test_publish_to_broker --publish-pact 2 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters