pact_broker-client 1.33.0 → 1.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 032b2528b1b15b999a2824688a69cfd919727aaf04e5740114a0394073fb10ca
4
- data.tar.gz: 615954f63d19d03e5da05ae4c5ee70b754f166d5c09778248fa95b160f057bab
3
+ metadata.gz: 108c1ab15ca6e36cc62cd630bdd73e716d83ed78ae9cdf718edb5abc7741ac3b
4
+ data.tar.gz: fa0e07f37153ce67e4b76a9e2ed32635e613d38972b60687e4eeff659e8d6dff
5
5
  SHA512:
6
- metadata.gz: 9c044af8573cf9fa6d42745eb19ebbb0b106f2581c8072666ec3969cee09d676a7bbf3d69d6c76f80ed7c53623e96c854a6124fc378140d3047fe7aaef69fe9b
7
- data.tar.gz: a9fdfed90ff342d500b4dd10973bbf3a45b1c12a37cbc8a8f705f2d98770244f6da59c0a7615e48df77425d90a8870d32dcc6230271045b0f4f6de25292b2c5a
6
+ metadata.gz: b3a851164b96ca422c7c3e683c389f5731c86e85fa8a7fe29501fb9b0719b4ac20fc8caed19654324765c2f29e1b253dfd12055268b45e59d75eef73507c834f
7
+ data.tar.gz: c9f836d70e375a8a6205855184fefaf0712cfeb4c46a14bd71433406ddf6aa445c50d76a3d36044d4427ac63b4ad14b2eab5890a16d502e68a4704a4b3cac540
@@ -1,3 +1,14 @@
1
+ <a name="v1.34.0"></a>
2
+ ### v1.34.0 (2020-11-20)
3
+
4
+ #### Features
5
+
6
+ * **pact publish**
7
+ * strip new lines from version numbers and tags ([5842d24](/../../commit/5842d24))
8
+
9
+ * **publish**
10
+ * update output text when pact already exists and merging ([9b849d3](/../../commit/9b849d3))
11
+
1
12
  <a name="v1.33.0"></a>
2
13
  ### v1.33.0 (2020-11-10)
3
14
 
@@ -16,8 +16,8 @@ module PactBroker
16
16
  def initialize pact_broker_base_url, pact_file_paths, consumer_version, tags, pact_broker_client_options={}
17
17
  @pact_broker_base_url = pact_broker_base_url
18
18
  @pact_file_paths = pact_file_paths
19
- @consumer_version = consumer_version
20
- @tags = tags
19
+ @consumer_version = consumer_version.respond_to?(:strip) ? consumer_version.strip : consumer_version
20
+ @tags = tags ? tags.collect{ |tag| tag.respond_to?(:strip) ? tag.strip : tag } : tags
21
21
  @pact_broker_client_options = pact_broker_client_options
22
22
  end
23
23
 
@@ -37,6 +37,10 @@ module PactBroker
37
37
  @pact_broker_client ||= PactBroker::Client::PactBrokerClient.new(base_url: pact_broker_base_url, client_options: pact_broker_client_options)
38
38
  end
39
39
 
40
+ def merge_on_server?
41
+ pact_broker_client_options[:write] == :merge
42
+ end
43
+
40
44
  def publish_pacts
41
45
  pact_files.group_by(&:pact_name).collect do | pact_name, pact_files |
42
46
  $stdout.puts "Merging #{pact_files.collect(&:path).join(", ")}" if pact_files.size > 1
@@ -91,7 +95,11 @@ module PactBroker
91
95
  Retry.while_error do
92
96
  pacts = pact_broker_client.pacticipants.versions.pacts
93
97
  if pacts.version_published?(consumer: pact.consumer_name, provider: pact.provider_name, consumer_version: consumer_version)
94
- $stdout.puts ::Term::ANSIColor.yellow("A pact for this consumer version is already published. Overwriting. (Note: Overwriting pacts is not recommended as it can lead to race conditions. Best practice is to provide a unique consumer version number for each publication.)")
98
+ if merge_on_server?
99
+ $stdout.puts "A pact for this consumer version is already published. Merging contents."
100
+ else
101
+ $stdout.puts ::Term::ANSIColor.yellow("A pact for this consumer version is already published. Overwriting. (Note: Overwriting pacts is not recommended as it can lead to race conditions. Best practice is to provide a unique consumer version number for each publication.)")
102
+ end
95
103
  end
96
104
 
97
105
  latest_pact_url = pacts.publish(pact_hash: pact, consumer_version: consumer_version)
@@ -1,5 +1,5 @@
1
1
  module PactBroker
2
2
  module Client
3
- VERSION = '1.33.0'
3
+ VERSION = '1.34.0'
4
4
  end
5
5
  end
@@ -62,12 +62,12 @@ module PactBroker
62
62
  end
63
63
 
64
64
  context "when publishing is successful" do
65
-
66
65
  it "puts the location of the latest pact" do
67
66
  allow($stdout).to receive(:puts)
68
67
  expect($stdout).to receive(:puts).with(/#{latest_pact_url}/)
69
68
  subject.call
70
69
  end
70
+
71
71
  it "returns true" do
72
72
  expect(subject.call).to be true
73
73
  end
@@ -142,6 +142,15 @@ module PactBroker
142
142
  end
143
143
  end
144
144
 
145
+ context "when consumer_version has a new line" do
146
+ let(:consumer_version) { "1\n" }
147
+
148
+ it "strips the new line" do
149
+ expect(pacts_client).to receive(:publish).with(pact_hash: pact_hash, consumer_version: "1")
150
+ subject.call
151
+ end
152
+ end
153
+
145
154
  context "when pact_broker_base_url is blank" do
146
155
  let(:pact_broker_base_url) { " " }
147
156
  it "raises a validation errror" do
@@ -164,6 +173,16 @@ module PactBroker
164
173
  subject.call
165
174
  end
166
175
 
176
+ context "when the tag has a new line on the end of it" do
177
+ let(:tags) { ["foo\n"] }
178
+
179
+ it "strips the newline" do
180
+ expect(pact_versions_client).to receive(:tag).with({pacticipant: "Consumer",
181
+ version: consumer_version, tag: "foo"})
182
+ subject.call
183
+ end
184
+ end
185
+
167
186
  context "when an error occurs tagging the pact" do
168
187
 
169
188
  before do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact_broker-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.33.0
4
+ version: 1.34.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Beth Skurrie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-10 00:00:00.000000000 Z
11
+ date: 2020-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty