Skip to content

Commit b6e1a8b

Browse files
committed
Issue: Cannot supply multiple files to pact-verifier
- PR: Added deprecation warning instead of making api-breaking change
1 parent 17aa15b commit b6e1a8b

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

pact/test/test_verify.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,25 @@ def test_all_options(self):
149149
self.mock_Popen.return_value.communicate.assert_called_once_with(
150150
timeout=60)
151151

152+
def test_deprecated_pact_urls(self):
153+
self.mock_Popen.return_value.returncode = 0
154+
result = self.runner.invoke(verify.main, [
155+
'--provider-base-url=http://localhost',
156+
'--pact-urls=./pacts/consumer-provider.json',
157+
'--pact-urls=./pacts/consumer-provider2.json'
158+
])
159+
self.assertEqual(result.exit_code, 0)
160+
self.assertIn(
161+
b'Multiple --pact-urls arguments are deprecated.',
162+
result.output_bytes)
163+
self.assertEqual(self.mock_Popen.call_count, 1)
164+
self.assertProcess(
165+
'--provider-base-url=http://localhost',
166+
'--pact-urls=./pacts/consumer-provider.json,'
167+
'./pacts/consumer-provider2.json')
168+
self.mock_Popen.return_value.communicate.assert_called_once_with(
169+
timeout=30)
170+
152171

153172
class path_existsTestCase(TestCase):
154173
def setUp(self):

pact/verify.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
default='',
2929
help='The URI(s) of the pact to verify.'
3030
' Can be an HTTP URI(s) or local file path(s).'
31-
' Provide multiple URI separated by a comma.')
31+
' Provide multiple URI separated by a comma.',
32+
multiple=True) # Remove in major version 1.0.0
3233
@click.option(
3334
'states_url', '--provider-states-url',
3435
help='URL to fetch the provider states for the given provider API.')
@@ -59,6 +60,7 @@ def main(base_url, pact_url, pact_urls, states_url, states_setup_url, username,
5960
pact-verifier --provider-base-url=http://localhost:8080 --pact-url=./pact
6061
""" # NOQA
6162
error = click.style('Error:', fg='red')
63+
warning = click.style('Warning:', fg='yellow')
6264
if bool(states_url) != bool(states_setup_url):
6365
click.echo(
6466
error
@@ -67,7 +69,16 @@ def main(base_url, pact_url, pact_urls, states_url, states_setup_url, username,
6769
raise click.Abort()
6870

6971
all_pact_urls = list(pact_url)
70-
all_pact_urls.extend(p for p in pact_urls.split(',') if p)
72+
for urls in pact_urls: # Remove in major version 1.0.0
73+
all_pact_urls.extend(p for p in urls.split(',') if p)
74+
75+
if len(pact_urls) > 1:
76+
click.echo(
77+
warning
78+
+ ' Multiple --pact-urls arguments are deprecated. '
79+
'Please provide a comma separated list of pacts to --pact-urls, '
80+
'or multiple --pact-url arguments.')
81+
7182
if not all_pact_urls:
7283
click.echo(
7384
error

0 commit comments

Comments
 (0)