pact-provider-verifier 1.34.0 → 1.35.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97f4e0f7b4b4f8daf7cb3960ce80e52a23119f2409abde541f51b64c653ae93a
4
- data.tar.gz: 6126a5247e221ca0fc05e2e4dd829023f75c8c3682e4a20ed497a629b24d4651
3
+ metadata.gz: 40aec54d6032b2a63f96e834a0308e98f6093af635bf5450b6575d05eb7a8549
4
+ data.tar.gz: f445fbe3035fc931018214d5bad5f8e616e8dda0ba682a8051081505503796a6
5
5
  SHA512:
6
- metadata.gz: 7640a18b5a9d83766ca30138172d43521e543c8509325c2566867aab51afeccccdad472b8cafef12d701b0f28f16950fddaf7d697b664d6742a024b307d137a2
7
- data.tar.gz: 762afb591b585af8a3a178f277e2084676df0a2b9336d39bd4ba89d078527d50b9d1134e0df41af212c8425dff1761aa0d4d26e72b0434c6fd89c0ae8296fa05
6
+ metadata.gz: 6d9941c91fed0ca20106fc24077c20556ea3757aa3ca176718e50d1c903e5d6608620c5160916c5396908e30ecd01fa58e4c4a1e25654cbbe26cfaf1da312c61
7
+ data.tar.gz: 1317675953ae4ebecaa9c289deac2a7f09fda5ef3778f6dfada6651d5bc52a49ae5629fa8b55b63ea1d0755942be26b151ec0ad0a7ac6687d1f8b5bb77f2e036
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ <a name="v1.35.0"></a>
2
+ ### v1.35.0 (2021-03-20)
3
+
4
+ #### Features
5
+
6
+ * Optionally fail when no pacts are found ([772e8fb](/../../commit/772e8fb))
7
+
1
8
  <a name="v1.34.0"></a>
2
9
  ### v1.34.0 (2021-02-01)
3
10
 
data/README.md CHANGED
@@ -97,6 +97,8 @@ Options:
97
97
  # The log level
98
98
 
99
99
  # Default: debug
100
+ [--fail-if-no-pacts-found]
101
+ # If specified, will fail when no pacts are found
100
102
 
101
103
  Description:
102
104
  The parameters used when fetching pacts dynamically from a Pact Broker are:
@@ -108,9 +110,9 @@ Description:
108
110
  --enable-pending
109
111
  --include-wip-pacts-since
110
112
 
111
- To fetch a pact from a known URL (eg. when a
112
- verification is triggered by a 'contract content changed' webhook), pass in the pact URL(s) as
113
- the first argument(s) to the command.
113
+ To verify a pact at a known URL (eg. when a verification is triggered by a 'contract content changed'
114
+ webhook), pass in the pact URL(s) as the first argument(s) to the command, and do NOT set any of the
115
+ other parameters apart from the base URL and credentials.
114
116
 
115
117
  To publish verification results for either of the above scenarios, set:
116
118
 
@@ -36,18 +36,23 @@ module Pact
36
36
 
37
37
  def call
38
38
  setup
39
-
40
- pact_urls = all_pact_urls
39
+ warn_empty_pact_set
41
40
  wait_until_provider_available
42
- exit_statuses = pact_urls.collect do |pact_uri|
41
+ pacts_pass_verification?
42
+ end
43
+
44
+ private
45
+
46
+ def pacts_pass_verification?
47
+ return false if all_pact_urls.empty? && options.fail_if_no_pacts_found
48
+
49
+ exit_statuses = all_pact_urls.collect do |pact_uri|
43
50
  verify_pact pact_uri
44
51
  end
45
52
 
46
53
  exit_statuses.all?{ | status | status == 0 }
47
54
  end
48
55
 
49
- private
50
-
51
56
 
52
57
  def setup
53
58
  configure_output
@@ -187,25 +192,34 @@ module Pact
187
192
  end
188
193
 
189
194
  def all_pact_urls
190
- http_client_options = {
191
- username: options.broker_username || ENV['PACT_BROKER_USERNAME'],
192
- password: options.broker_password || ENV['PACT_BROKER_PASSWORD'],
193
- token: options.broker_token || ENV['PACT_BROKER_TOKEN'],
194
- verbose: verbose?
195
- }
196
- opts = {
197
- enable_pending: options.enable_pending,
198
- include_wip_pacts_since: options.include_wip_pacts_since
199
- }
200
- AggregatePactConfigs.call(
201
- pact_urls,
202
- options.provider,
203
- consumer_version_tags,
204
- consumer_version_selectors,
205
- provider_version_tags,
206
- options.pact_broker_base_url || ENV['PACT_BROKER_BASE_URL'],
207
- http_client_options,
208
- opts)
195
+ @all_pact_urls ||= begin
196
+ http_client_options = {
197
+ username: options.broker_username || ENV['PACT_BROKER_USERNAME'],
198
+ password: options.broker_password || ENV['PACT_BROKER_PASSWORD'],
199
+ token: options.broker_token || ENV['PACT_BROKER_TOKEN'],
200
+ verbose: verbose?
201
+ }
202
+ opts = {
203
+ enable_pending: options.enable_pending,
204
+ include_wip_pacts_since: options.include_wip_pacts_since
205
+ }
206
+ AggregatePactConfigs.call(
207
+ pact_urls,
208
+ options.provider,
209
+ consumer_version_tags,
210
+ consumer_version_selectors,
211
+ provider_version_tags,
212
+ options.pact_broker_base_url || ENV['PACT_BROKER_BASE_URL'],
213
+ http_client_options,
214
+ opts)
215
+ end
216
+ end
217
+
218
+ def warn_empty_pact_set
219
+ if all_pact_urls.empty?
220
+ level = options.fail_if_no_pacts_found ? "ERROR" : "WARN"
221
+ $stderr.puts "#{level}: No pacts were found for the consumer versions selected"
222
+ end
209
223
  end
210
224
 
211
225
  def require_pact_project_pact_helper
@@ -7,7 +7,7 @@ The parameters used when fetching pacts dynamically from a Pact Broker are:
7
7
  --enable-pending
8
8
  --include-wip-pacts-since
9
9
 
10
- To fetch a pact from a known URL (eg. when a verification is triggered by a 'contract content changed' webhook), pass in the pact URL(s) as the first argument(s) to the command.
10
+ To verify a pact at a known URL (eg. when a verification is triggered by a 'contract content changed' webhook), pass in the pact URL(s) as the first argument(s) to the command, and do NOT set any of the other parameters apart from the base URL and credentials.
11
11
 
12
12
  To publish verification results for either of the above scenarios, set:
13
13
 
@@ -38,6 +38,7 @@ module Pact
38
38
  method_option :wait, banner: "SECONDS", required: false, type: :numeric, desc: "The number of seconds to poll for the provider to become available before running the verification", default: 0
39
39
  method_option :log_dir, desc: "The directory for the pact.log file"
40
40
  method_option :log_level, desc: "The log level", default: "debug"
41
+ method_option :fail_if_no_pacts_found, desc: "If specified, will fail when no pacts are found", required: false, type: :boolean, default: false
41
42
 
42
43
  def verify(*pact_urls)
43
44
  require 'pact/provider_verifier/app'
@@ -1,5 +1,5 @@
1
1
  module Pact
2
2
  module ProviderVerifier
3
- VERSION = "1.34.0"
3
+ VERSION = "1.35.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact-provider-verifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.34.0
4
+ version: 1.35.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Fellows
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-02-01 00:00:00.000000000 Z
12
+ date: 2021-03-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -342,7 +342,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
342
342
  - !ruby/object:Gem::Version
343
343
  version: '0'
344
344
  requirements: []
345
- rubygems_version: 3.2.7
345
+ rubygems_version: 3.2.15
346
346
  signing_key:
347
347
  specification_version: 4
348
348
  summary: Provides a Pact verification service for use with Pact