Skip to content

Commit efe6206

Browse files
committed
docs: add consumer_version
Consumer version was recently added (in 3.2). Signed-off-by: JP-Ellis <josh@jpellis.me>
1 parent 0f025a3 commit efe6206

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

MIGRATION.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,16 @@ broker_builder = (
292292
)
293293
.include_pending()
294294
.provider_branch('main')
295-
.consumer_tags('main', 'develop')
295+
.consumer_version(branch='main')
296+
.consumer_version(branch='develop')
296297
.build()
297298
)
298299
```
299300

300301
The `selector=True` argument returns a [`BrokerSelectorBuilder`][pact.verifier.BrokerSelectorBuilder] instance, which provides methods to configure which pacts to fetch. The `build()` call finalizes the configuration and returns the `Verifier` instance which can then be further configured.
301302

303+
The `consumer_version` method provides fine-grained control over which consumer pacts are verified and can be called multiple times to add multiple selectors (combined with a logical OR). The older `consumer_versions` method is now deprecated in favor of `consumer_version`.
304+
302305
///
303306

304307
#### Provider State Handling

docs/provider.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,38 @@ def test_provider_with_selectors():
9696
)
9797
.include_pending() # Include pending pacts
9898
.include_wip_since("2023-01-01") # Include WIP pacts since date
99-
.provider_tags("main", "develop")
100-
.consumer_tags("production", "main")
99+
.provider_branch("main")
100+
.consumer_version(branch="main") # Specific consumer version selectors
101+
.consumer_version(branch="develop") # Can be called multiple times
101102
.build() # Build the selector
102103
)
103104

104105
verifier.verify()
105106
```
106107

108+
#### Consumer Version Selectors
109+
110+
The `consumer_version` method provides fine-grained control over which consumer pacts are verified. It can be called multiple times to add multiple selectors, which are combined with a logical OR (pacts matching any selector will be included).
111+
112+
Common use cases:
113+
114+
```python
115+
# Verify pacts from a specific branch
116+
.consumer_version(branch="feature/new-api")
117+
118+
# Verify pacts from deployed or released versions
119+
.consumer_version(deployed_or_released=True)
120+
121+
# Verify pacts from main branch
122+
.consumer_version(main_branch=True)
123+
124+
# Verify pacts from a specific consumer only
125+
.consumer_version(consumer="mobile-app", branch="main")
126+
127+
# Verify pacts from a specific environment
128+
.consumer_version(deployed=True, environment="production")
129+
```
130+
107131
More information on the selector options is available in the [API reference][pact.verifier.BrokerSelectorBuilder].
108132

109133
## Logging
@@ -139,7 +163,6 @@ if "CI" in os.environ:
139163
verifier.set_publish_options( # (1)
140164
version="1.2.3",
141165
branch="main",
142-
tags=["production"],
143166
)
144167

145168
verifier.verify()

0 commit comments

Comments
 (0)