Skip to content

Commit 5a99528

Browse files
committed
feat(cli): add consumer-version-selector option
1 parent 19b4be3 commit 5a99528

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

pact/cli/verify.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,26 @@
3737
@click.option(
3838
'username', '--pact-broker-username',
3939
envvar='PACT_BROKER_USERNAME',
40-
help='Username for Pact Broker basic authentication.')
40+
help='Username for Pact Broker basic authentication. Can also be specified'
41+
' via the environment variable PACT_BROKER_USERNAME')
4142
@click.option(
4243
'broker_base_url', '--pact-broker-url',
4344
default='',
4445
envvar='PACT_BROKER_BASE_URL',
45-
help='Base URl for the Pact Broker instance to publish pacts to.')
46+
help='Base URl for the Pact Broker instance to publish pacts to. Can also be specified'
47+
' via the environment variable PACT_BROKER_BASE_URL')
4648
@click.option(
4749
'consumer_version_tag', '--consumer-version-tag',
4850
default='',
4951
multiple=True,
5052
help='Retrieve the latest pacts with this consumer version tag. '
51-
'Used in conjunction with --provider.')
53+
'Used in conjunction with --provider. May be specified multiple times.')
54+
@click.option(
55+
'consumer_version_selector', '--consumer-version-selector',
56+
default='',
57+
multiple=True,
58+
help='Retrieve the latest pacts with this consumer version selector. '
59+
'Used in conjunction with --provider. May be specified multiple times.')
5260
@click.option(
5361
'provider_version_tag', '--provider-version-tag',
5462
default='',
@@ -80,7 +88,7 @@
8088
@click.option(
8189
'timeout', '-t', '--timeout',
8290
default=30,
83-
help='The duration in seconds we should wait to confirm verification'
91+
help='The duration in seconds we should wait to confirm that the verification'
8492
' process was successful. Defaults to 30.',
8593
type=int)
8694
@click.option(
@@ -107,9 +115,9 @@
107115
'log_level', '--log-level',
108116
help='The logging level.')
109117
def main(pacts, base_url, pact_url, pact_urls, states_url, states_setup_url,
110-
username, broker_base_url, consumer_version_tag, provider_version_tag,
111-
password, token, provider, headers, timeout, provider_app_version,
112-
publish_verification_results, verbose, log_dir, log_level):
118+
username, broker_base_url, consumer_version_tag, consumer_version_selector,
119+
provider_version_tag, password, token, provider, headers, timeout,
120+
provider_app_version, publish_verification_results, verbose, log_dir, log_level):
113121
"""
114122
Verify one or more contracts against a provider service.
115123
@@ -162,6 +170,7 @@ def main(pacts, base_url, pact_url, pact_urls, states_url, states_setup_url,
162170
'timeout': timeout,
163171
'verbose': verbose,
164172
'consumer_tags': list(consumer_version_tag),
173+
'consumer_selectors': list(consumer_version_selector),
165174
'provider_tags': list(provider_version_tag),
166175
'provider_states_setup_url': states_setup_url
167176
}

pact/verify_wrapper.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ def call_verify(self, *pacts, provider_base_url, provider, **kwargs):
175175
command.extend(['{}={}'.format('--custom-provider-header', header)])
176176
for tag in kwargs.get('consumer_tags', []):
177177
command.extend(["--consumer-version-tag={}".format(tag)])
178+
for tag in kwargs.get('consumer_selectors', []):
179+
command.extend(["--consumer-version-selector={}".format(tag)])
178180
for tag in kwargs.get('provider_tags', []):
179181
command.extend(["--provider-version-tag={}".format(tag)])
180182

tests/cli/test_verify.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ def test_all_broker_options(self, mock_wrapper):
259259
'--pact-broker-url=http://localhost/broker',
260260
'--consumer-version-tag=prod',
261261
'--consumer-version-tag=dev',
262+
'--consumer-version-selector={"tag": "master", "latest": true}',
263+
'--consumer-version-selector={"tag": "staging", "latest": true}',
262264
'--provider-version-tag=dev',
263265
'--provider-version-tag=qa',
264266
'--provider-base-url=http://localhost',
@@ -284,6 +286,8 @@ def test_all_broker_options(self, mock_wrapper):
284286
broker_token='token',
285287
broker_url='http://localhost/broker',
286288
consumer_tags=['prod', 'dev'],
289+
consumer_selectors=['{"tag": "master", "latest": true}',
290+
'{"tag": "staging", "latest": true}'],
287291
provider_tags=['dev', 'qa'],
288292
provider_app_version='1.2.3',
289293
# custom_provider_header=['Authorization: Basic cGFj', 'CustomHeader: somevalue'],

0 commit comments

Comments
 (0)