Skip to content

Commit

Permalink
Issue: Cannot supply multiple files to pact-verifier
Browse files Browse the repository at this point in the history
 - PR: Added deprecation warning instead of making api-breaking change
  • Loading branch information
SimKev2 committed Jun 27, 2017
1 parent 17aa15b commit b6e1a8b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
19 changes: 19 additions & 0 deletions pact/test/test_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,25 @@ def test_all_options(self):
self.mock_Popen.return_value.communicate.assert_called_once_with(
timeout=60)

def test_deprecated_pact_urls(self):
self.mock_Popen.return_value.returncode = 0
result = self.runner.invoke(verify.main, [
'--provider-base-url=http://localhost',
'--pact-urls=./pacts/consumer-provider.json',
'--pact-urls=./pacts/consumer-provider2.json'
])
self.assertEqual(result.exit_code, 0)
self.assertIn(
b'Multiple --pact-urls arguments are deprecated.',
result.output_bytes)
self.assertEqual(self.mock_Popen.call_count, 1)
self.assertProcess(
'--provider-base-url=http://localhost',
'--pact-urls=./pacts/consumer-provider.json,'
'./pacts/consumer-provider2.json')
self.mock_Popen.return_value.communicate.assert_called_once_with(
timeout=30)


class path_existsTestCase(TestCase):
def setUp(self):
Expand Down
15 changes: 13 additions & 2 deletions pact/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
default='',
help='The URI(s) of the pact to verify.'
' Can be an HTTP URI(s) or local file path(s).'
' Provide multiple URI separated by a comma.')
' Provide multiple URI separated by a comma.',
multiple=True) # Remove in major version 1.0.0
@click.option(
'states_url', '--provider-states-url',
help='URL to fetch the provider states for the given provider API.')
Expand Down Expand Up @@ -59,6 +60,7 @@ def main(base_url, pact_url, pact_urls, states_url, states_setup_url, username,
pact-verifier --provider-base-url=http://localhost:8080 --pact-url=./pact
""" # NOQA
error = click.style('Error:', fg='red')
warning = click.style('Warning:', fg='yellow')
if bool(states_url) != bool(states_setup_url):
click.echo(
error
Expand All @@ -67,7 +69,16 @@ def main(base_url, pact_url, pact_urls, states_url, states_setup_url, username,
raise click.Abort()

all_pact_urls = list(pact_url)
all_pact_urls.extend(p for p in pact_urls.split(',') if p)
for urls in pact_urls: # Remove in major version 1.0.0
all_pact_urls.extend(p for p in urls.split(',') if p)

if len(pact_urls) > 1:
click.echo(
warning
+ ' Multiple --pact-urls arguments are deprecated. '
'Please provide a comma separated list of pacts to --pact-urls, '
'or multiple --pact-url arguments.')

if not all_pact_urls:
click.echo(
error
Expand Down

0 comments on commit b6e1a8b

Please sign in to comment.