pact_broker-client 1.51.0 → 1.51.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/doc/pacts/markdown/Pact Broker Client - Pact Broker.md +0 -101
- data/lib/pact_broker/client/publish_pacts_the_old_way.rb +4 -49
- data/lib/pact_broker/client/version.rb +1 -1
- data/spec/lib/pact_broker/client/publish_pacts_the_old_way_spec.rb +3 -74
- data/spec/pacts/pact_broker_client-pact_broker.json +0 -104
- metadata +1 -3
- data/spec/service_providers/pact_broker_client_create_version_spec.rb +0 -88
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2e9f7e405595ad05502d071f02a3af96cb551acac1e2431b046a59b3253ebde
|
4
|
+
data.tar.gz: d8ff809310b56b9a1f8c7ffc104c2da5690c84973b08f536860eacfde45bbfce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb977bc1fe55c901c704293e3046d52e39a2a30cef55282e03c6c4afa1f3f6bb06adf038686a871a8d8df1675415136ba8b2eaa79d4bc02449a6b52fde2aca85
|
7
|
+
data.tar.gz: 6b650d970bfa921d83a160051c765f8e82d140017a32b32f1b145454f2023829ce1ebfc3dd30102d51f136e80731f5b251cc9bb9d6b0c47f5371586cd7fd19a5
|
data/CHANGELOG.md
CHANGED
@@ -40,8 +40,6 @@
|
|
40
40
|
|
41
41
|
* [A request for the index resource](#a_request_for_the_index_resource_given_the_pb:pacticipant-version_and_pb:environments_relations_exist_in_the_index_resource) given the pb:pacticipant-version and pb:environments relations exist in the index resource
|
42
42
|
|
43
|
-
* [A request for the index resource](#a_request_for_the_index_resource_given_the_pb:pacticipant-version_relation_exists_in_the_index_resource) given the pb:pacticipant-version relation exists in the index resource
|
44
|
-
|
45
43
|
* [A request for the index resource](#a_request_for_the_index_resource_given_the_pb:publish-contracts_relations_exists_in_the_index_resource) given the pb:publish-contracts relations exists in the index resource
|
46
44
|
|
47
45
|
* [A request for the index resource with the webhook relation](#a_request_for_the_index_resource_with_the_webhook_relation)
|
@@ -58,10 +56,6 @@
|
|
58
56
|
|
59
57
|
* [A request to create a pacticipant](#a_request_to_create_a_pacticipant)
|
60
58
|
|
61
|
-
* [A request to create a pacticipant version](#a_request_to_create_a_pacticipant_version_given_version_26f353580936ad3b9baddb17b00e84f33c69e7cb_of_pacticipant_Foo_does_exist) given version 26f353580936ad3b9baddb17b00e84f33c69e7cb of pacticipant Foo does exist
|
62
|
-
|
63
|
-
* [A request to create a pacticipant version](#a_request_to_create_a_pacticipant_version_given_version_26f353580936ad3b9baddb17b00e84f33c69e7cb_of_pacticipant_Foo_does_not_exist) given version 26f353580936ad3b9baddb17b00e84f33c69e7cb of pacticipant Foo does not exist
|
64
|
-
|
65
59
|
* [A request to create a webhook for a consumer and provider](#a_request_to_create_a_webhook_for_a_consumer_and_provider_given_'Condor'_does_not_exist_in_the_pact-broker) given 'Condor' does not exist in the pact-broker
|
66
60
|
|
67
61
|
* [A request to create a webhook with a JSON body and a uuid](#a_request_to_create_a_webhook_with_a_JSON_body_and_a_uuid_given_the_'Pricing_Service'_and_'Condor'_already_exist_in_the_pact-broker) given the 'Pricing Service' and 'Condor' already exist in the pact-broker
|
@@ -859,33 +853,6 @@ Pact Broker will respond with:
|
|
859
853
|
}
|
860
854
|
}
|
861
855
|
```
|
862
|
-
<a name="a_request_for_the_index_resource_given_the_pb:pacticipant-version_relation_exists_in_the_index_resource"></a>
|
863
|
-
Given **the pb:pacticipant-version relation exists in the index resource**, upon receiving **a request for the index resource** from Pact Broker Client, with
|
864
|
-
```json
|
865
|
-
{
|
866
|
-
"method": "get",
|
867
|
-
"path": "/",
|
868
|
-
"headers": {
|
869
|
-
"Accept": "application/hal+json"
|
870
|
-
}
|
871
|
-
}
|
872
|
-
```
|
873
|
-
Pact Broker will respond with:
|
874
|
-
```json
|
875
|
-
{
|
876
|
-
"status": 200,
|
877
|
-
"headers": {
|
878
|
-
"Content-Type": "application/hal+json;charset=utf-8"
|
879
|
-
},
|
880
|
-
"body": {
|
881
|
-
"_links": {
|
882
|
-
"pb:pacticipant-version": {
|
883
|
-
"href": "http://localhost:1234/HAL-REL-PLACEHOLDER-INDEX-PB-PACTICIPANT-VERSION-{pacticipant}-{version}"
|
884
|
-
}
|
885
|
-
}
|
886
|
-
}
|
887
|
-
}
|
888
|
-
```
|
889
856
|
<a name="a_request_for_the_index_resource_given_the_pb:publish-contracts_relations_exists_in_the_index_resource"></a>
|
890
857
|
Given **the pb:publish-contracts relations exists in the index resource**, upon receiving **a request for the index resource** from Pact Broker Client, with
|
891
858
|
```json
|
@@ -1165,74 +1132,6 @@ Pact Broker will respond with:
|
|
1165
1132
|
}
|
1166
1133
|
}
|
1167
1134
|
```
|
1168
|
-
<a name="a_request_to_create_a_pacticipant_version_given_version_26f353580936ad3b9baddb17b00e84f33c69e7cb_of_pacticipant_Foo_does_exist"></a>
|
1169
|
-
Given **version 26f353580936ad3b9baddb17b00e84f33c69e7cb of pacticipant Foo does exist**, upon receiving **a request to create a pacticipant version** from Pact Broker Client, with
|
1170
|
-
```json
|
1171
|
-
{
|
1172
|
-
"method": "put",
|
1173
|
-
"path": "/HAL-REL-PLACEHOLDER-INDEX-PB-PACTICIPANT-VERSION-Foo-26f353580936ad3b9baddb17b00e84f33c69e7cb",
|
1174
|
-
"headers": {
|
1175
|
-
"Content-Type": "application/json",
|
1176
|
-
"Accept": "application/hal+json"
|
1177
|
-
},
|
1178
|
-
"body": {
|
1179
|
-
"branch": "main",
|
1180
|
-
"buildUrl": "http://my-ci/builds/1"
|
1181
|
-
}
|
1182
|
-
}
|
1183
|
-
```
|
1184
|
-
Pact Broker will respond with:
|
1185
|
-
```json
|
1186
|
-
{
|
1187
|
-
"status": 200,
|
1188
|
-
"headers": {
|
1189
|
-
"Content-Type": "application/hal+json;charset=utf-8"
|
1190
|
-
},
|
1191
|
-
"body": {
|
1192
|
-
"number": "26f353580936ad3b9baddb17b00e84f33c69e7cb",
|
1193
|
-
"buildUrl": "http://my-ci/builds/1",
|
1194
|
-
"_links": {
|
1195
|
-
"self": {
|
1196
|
-
"href": "http://localhost:1234/some-url"
|
1197
|
-
}
|
1198
|
-
}
|
1199
|
-
}
|
1200
|
-
}
|
1201
|
-
```
|
1202
|
-
<a name="a_request_to_create_a_pacticipant_version_given_version_26f353580936ad3b9baddb17b00e84f33c69e7cb_of_pacticipant_Foo_does_not_exist"></a>
|
1203
|
-
Given **version 26f353580936ad3b9baddb17b00e84f33c69e7cb of pacticipant Foo does not exist**, upon receiving **a request to create a pacticipant version** from Pact Broker Client, with
|
1204
|
-
```json
|
1205
|
-
{
|
1206
|
-
"method": "put",
|
1207
|
-
"path": "/HAL-REL-PLACEHOLDER-INDEX-PB-PACTICIPANT-VERSION-Foo-26f353580936ad3b9baddb17b00e84f33c69e7cb",
|
1208
|
-
"headers": {
|
1209
|
-
"Content-Type": "application/json",
|
1210
|
-
"Accept": "application/hal+json"
|
1211
|
-
},
|
1212
|
-
"body": {
|
1213
|
-
"branch": "main",
|
1214
|
-
"buildUrl": "http://my-ci/builds/1"
|
1215
|
-
}
|
1216
|
-
}
|
1217
|
-
```
|
1218
|
-
Pact Broker will respond with:
|
1219
|
-
```json
|
1220
|
-
{
|
1221
|
-
"status": 201,
|
1222
|
-
"headers": {
|
1223
|
-
"Content-Type": "application/hal+json;charset=utf-8"
|
1224
|
-
},
|
1225
|
-
"body": {
|
1226
|
-
"number": "26f353580936ad3b9baddb17b00e84f33c69e7cb",
|
1227
|
-
"buildUrl": "http://my-ci/builds/1",
|
1228
|
-
"_links": {
|
1229
|
-
"self": {
|
1230
|
-
"href": "http://localhost:1234/some-url"
|
1231
|
-
}
|
1232
|
-
}
|
1233
|
-
}
|
1234
|
-
}
|
1235
|
-
```
|
1236
1135
|
<a name="a_request_to_create_a_webhook_for_a_consumer_and_provider_given_'Condor'_does_not_exist_in_the_pact-broker"></a>
|
1237
1136
|
Given **'Condor' does not exist in the pact-broker**, upon receiving **a request to create a webhook for a consumer and provider** from Pact Broker Client, with
|
1238
1137
|
```json
|
@@ -25,14 +25,13 @@ module PactBroker
|
|
25
25
|
@branch = consumer_version_params[:branch]
|
26
26
|
@build_url = consumer_version_params[:build_url]
|
27
27
|
@tags = consumer_version_params[:tags] ? consumer_version_params[:tags].collect{ |tag| tag.respond_to?(:strip) ? tag.strip : tag } : []
|
28
|
-
@version_required = consumer_version_params[:version_required]
|
29
28
|
@pact_broker_client_options = pact_broker_client_options
|
30
29
|
end
|
31
30
|
|
32
31
|
def call
|
33
32
|
validate
|
34
33
|
$stdout.puts("")
|
35
|
-
result =
|
34
|
+
result = apply_tags && publish_pacts
|
36
35
|
$stdout.puts("")
|
37
36
|
if result
|
38
37
|
PactBroker::Client::CommandResult.new(true)
|
@@ -59,10 +58,6 @@ module PactBroker
|
|
59
58
|
end
|
60
59
|
end
|
61
60
|
|
62
|
-
def can_create_version_with_branch?
|
63
|
-
@can_create_version_with_branch ||= index_resource.can?('pb:pacticipant-version')
|
64
|
-
end
|
65
|
-
|
66
61
|
def merge_on_server?
|
67
62
|
pact_broker_client_options[:write] == :merge
|
68
63
|
end
|
@@ -96,49 +91,6 @@ module PactBroker
|
|
96
91
|
end
|
97
92
|
end
|
98
93
|
|
99
|
-
def create_consumer_versions
|
100
|
-
if create_versions?
|
101
|
-
consumer_names.collect do | consumer_name |
|
102
|
-
create_version(index_resource, consumer_name)
|
103
|
-
end
|
104
|
-
true
|
105
|
-
else
|
106
|
-
true
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
def create_versions?
|
111
|
-
if version_required
|
112
|
-
if can_create_version_with_branch?
|
113
|
-
true
|
114
|
-
else
|
115
|
-
raise PactBroker::Client::Error.new("This version of the Pact Broker does not support versions with branches or build URLs. Please upgrade your broker to 2.76.2 or later.")
|
116
|
-
end
|
117
|
-
elsif (branch || build_url) && can_create_version_with_branch?
|
118
|
-
true
|
119
|
-
else
|
120
|
-
false
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
def create_version(index_resource, consumer_name)
|
125
|
-
Retry.while_error do
|
126
|
-
version_resource = index_resource._link('pb:pacticipant-version').expand(version: consumer_version_number, pacticipant: consumer_name).put(version_body).assert_success!
|
127
|
-
message = if version_resource.response.status == 200
|
128
|
-
"Replaced version #{consumer_version_number} of #{consumer_name}"
|
129
|
-
else
|
130
|
-
"Created version #{consumer_version_number} of #{consumer_name}"
|
131
|
-
end
|
132
|
-
|
133
|
-
message = message + " (branch #{branch})" if branch
|
134
|
-
$stdout.puts message
|
135
|
-
if version_resource.response.status == 200
|
136
|
-
$stdout.puts ::Term::ANSIColor.yellow("Replacing the version resource is not recommended under normal circumstances and may indicate that you have not configured your Pact pipeline correctly (unless you are just re-running a build for a particular commit). For more information see https://docs.pact.io/versioning")
|
137
|
-
end
|
138
|
-
true
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
94
|
def version_body
|
143
95
|
{
|
144
96
|
branch: branch,
|
@@ -185,6 +137,9 @@ module PactBroker
|
|
185
137
|
end
|
186
138
|
|
187
139
|
def validate
|
140
|
+
if branch || build_url
|
141
|
+
$stdout.puts ::Term::ANSIColor.yellow("WARN: This version of the Pact Broker does not support versions with branches or build URLs. Please upgrade your broker to 2.86.0 or later.")
|
142
|
+
end
|
188
143
|
raise PactBroker::Client::Error.new("Please specify the consumer_version_number") unless (consumer_version_number && consumer_version_number.to_s.strip.size > 0)
|
189
144
|
raise PactBroker::Client::Error.new("Please specify the pact_broker_base_url") unless (pact_broker_base_url && pact_broker_base_url.to_s.strip.size > 0)
|
190
145
|
raise PactBroker::Client::Error.new("No pact files found") unless (pact_file_paths && pact_file_paths.any?)
|
@@ -263,80 +263,9 @@ module PactBroker
|
|
263
263
|
context "when the broker does not support creation of a version with a branch but a branch is specified" do
|
264
264
|
let(:branch) { "main" }
|
265
265
|
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
it "raises an error" do
|
270
|
-
expect { subject.call }.to raise_error PactBroker::Client::Error
|
271
|
-
end
|
272
|
-
end
|
273
|
-
end
|
274
|
-
|
275
|
-
context "when the broker supports creation of a version with a branch" do
|
276
|
-
before do
|
277
|
-
allow(version_link).to receive(:expand).and_return(version_link)
|
278
|
-
allow(version_resource).to receive(:assert_success!).and_return(version_resource)
|
279
|
-
allow(version_resource).to receive_message_chain(:response, :status).and_return(version_creation_response_status)
|
280
|
-
end
|
281
|
-
let(:can_create_version) { true }
|
282
|
-
let(:version_link) { instance_double("PactBroker::Client::Hal::Link", put: version_resource) }
|
283
|
-
let(:version_resource) { instance_double("PactBroker::Client::Hal::Entity") }
|
284
|
-
let(:version_creation_response_status) { 201 }
|
285
|
-
|
286
|
-
before do
|
287
|
-
allow(index_resource).to receive(:_link).and_return(version_link)
|
288
|
-
end
|
289
|
-
|
290
|
-
context "when there is a branch, build_url or tags specified" do
|
291
|
-
let(:tags) { ["dev"] }
|
292
|
-
let(:branch) { ["main"] }
|
293
|
-
let(:build_url) { "build_url" }
|
294
|
-
|
295
|
-
it "creates a version with the branch, build_url and tags" do
|
296
|
-
expect(index_resource).to receive(:_link)
|
297
|
-
expect(version_link).to receive(:expand).with(pacticipant: "Consumer", version: "1.2.3")
|
298
|
-
expect(version_link).to receive(:put).with(branch: branch, buildUrl: build_url)
|
299
|
-
subject.call
|
300
|
-
end
|
301
|
-
|
302
|
-
context "when there is a branch but no tags" do
|
303
|
-
let(:tags) { [] }
|
304
|
-
|
305
|
-
it "does not set the tags, as this would overwrite the existing ones - not sure about this implementation" do
|
306
|
-
expect(version_link).to receive(:put).with(branch: branch, buildUrl: build_url)
|
307
|
-
subject.call
|
308
|
-
end
|
309
|
-
end
|
310
|
-
|
311
|
-
context "when the version response status is 201" do
|
312
|
-
it "puts a message indicating the version was created" do
|
313
|
-
expect($stdout).to receive(:puts).with(/Created/)
|
314
|
-
subject.call
|
315
|
-
end
|
316
|
-
end
|
317
|
-
|
318
|
-
context "when the version response status is 200" do
|
319
|
-
let(:version_creation_response_status) { 200 }
|
320
|
-
|
321
|
-
it "puts a message indicating the version was replaced" do
|
322
|
-
expect($stdout).to receive(:puts).with(/Replaced/)
|
323
|
-
subject.call
|
324
|
-
end
|
325
|
-
end
|
326
|
-
end
|
327
|
-
|
328
|
-
context "when there is no branch, tags or build_url specified" do
|
329
|
-
before do
|
330
|
-
allow(Retry).to receive(:while_error) { |&block| block.call }
|
331
|
-
end
|
332
|
-
let(:tags) { [] }
|
333
|
-
let(:branch) { nil }
|
334
|
-
let(:build_url) { nil }
|
335
|
-
|
336
|
-
it "does not create a version resource" do
|
337
|
-
expect(index_resource).to_not receive(:_link)
|
338
|
-
subject.call
|
339
|
-
end
|
266
|
+
it "logs a warning" do
|
267
|
+
expect($stdout).to receive(:puts).with(/WARN: This version/)
|
268
|
+
subject.call
|
340
269
|
end
|
341
270
|
end
|
342
271
|
end
|
@@ -186,110 +186,6 @@
|
|
186
186
|
}
|
187
187
|
}
|
188
188
|
},
|
189
|
-
{
|
190
|
-
"description": "a request for the index resource",
|
191
|
-
"providerState": "the pb:pacticipant-version relation exists in the index resource",
|
192
|
-
"request": {
|
193
|
-
"method": "get",
|
194
|
-
"path": "/",
|
195
|
-
"headers": {
|
196
|
-
"Accept": "application/hal+json"
|
197
|
-
}
|
198
|
-
},
|
199
|
-
"response": {
|
200
|
-
"status": 200,
|
201
|
-
"headers": {
|
202
|
-
"Content-Type": "application/hal+json;charset=utf-8"
|
203
|
-
},
|
204
|
-
"body": {
|
205
|
-
"_links": {
|
206
|
-
"pb:pacticipant-version": {
|
207
|
-
"href": "http://localhost:1234/HAL-REL-PLACEHOLDER-INDEX-PB-PACTICIPANT-VERSION-{pacticipant}-{version}"
|
208
|
-
}
|
209
|
-
}
|
210
|
-
},
|
211
|
-
"matchingRules": {
|
212
|
-
"$.body._links.pb:pacticipant-version.href": {
|
213
|
-
"match": "regex",
|
214
|
-
"regex": "http:\\/\\/.*{pacticipant}.*{version}"
|
215
|
-
}
|
216
|
-
}
|
217
|
-
}
|
218
|
-
},
|
219
|
-
{
|
220
|
-
"description": "a request to create a pacticipant version",
|
221
|
-
"providerState": "version 26f353580936ad3b9baddb17b00e84f33c69e7cb of pacticipant Foo does not exist",
|
222
|
-
"request": {
|
223
|
-
"method": "put",
|
224
|
-
"path": "/HAL-REL-PLACEHOLDER-INDEX-PB-PACTICIPANT-VERSION-Foo-26f353580936ad3b9baddb17b00e84f33c69e7cb",
|
225
|
-
"headers": {
|
226
|
-
"Content-Type": "application/json",
|
227
|
-
"Accept": "application/hal+json"
|
228
|
-
},
|
229
|
-
"body": {
|
230
|
-
"branch": "main",
|
231
|
-
"buildUrl": "http://my-ci/builds/1"
|
232
|
-
}
|
233
|
-
},
|
234
|
-
"response": {
|
235
|
-
"status": 201,
|
236
|
-
"headers": {
|
237
|
-
"Content-Type": "application/hal+json;charset=utf-8"
|
238
|
-
},
|
239
|
-
"body": {
|
240
|
-
"number": "26f353580936ad3b9baddb17b00e84f33c69e7cb",
|
241
|
-
"buildUrl": "http://my-ci/builds/1",
|
242
|
-
"_links": {
|
243
|
-
"self": {
|
244
|
-
"href": "http://localhost:1234/some-url"
|
245
|
-
}
|
246
|
-
}
|
247
|
-
},
|
248
|
-
"matchingRules": {
|
249
|
-
"$.body._links.self.href": {
|
250
|
-
"match": "regex",
|
251
|
-
"regex": "http:\\/\\/.*"
|
252
|
-
}
|
253
|
-
}
|
254
|
-
}
|
255
|
-
},
|
256
|
-
{
|
257
|
-
"description": "a request to create a pacticipant version",
|
258
|
-
"providerState": "version 26f353580936ad3b9baddb17b00e84f33c69e7cb of pacticipant Foo does exist",
|
259
|
-
"request": {
|
260
|
-
"method": "put",
|
261
|
-
"path": "/HAL-REL-PLACEHOLDER-INDEX-PB-PACTICIPANT-VERSION-Foo-26f353580936ad3b9baddb17b00e84f33c69e7cb",
|
262
|
-
"headers": {
|
263
|
-
"Content-Type": "application/json",
|
264
|
-
"Accept": "application/hal+json"
|
265
|
-
},
|
266
|
-
"body": {
|
267
|
-
"branch": "main",
|
268
|
-
"buildUrl": "http://my-ci/builds/1"
|
269
|
-
}
|
270
|
-
},
|
271
|
-
"response": {
|
272
|
-
"status": 200,
|
273
|
-
"headers": {
|
274
|
-
"Content-Type": "application/hal+json;charset=utf-8"
|
275
|
-
},
|
276
|
-
"body": {
|
277
|
-
"number": "26f353580936ad3b9baddb17b00e84f33c69e7cb",
|
278
|
-
"buildUrl": "http://my-ci/builds/1",
|
279
|
-
"_links": {
|
280
|
-
"self": {
|
281
|
-
"href": "http://localhost:1234/some-url"
|
282
|
-
}
|
283
|
-
}
|
284
|
-
},
|
285
|
-
"matchingRules": {
|
286
|
-
"$.body._links.self.href": {
|
287
|
-
"match": "regex",
|
288
|
-
"regex": "http:\\/\\/.*"
|
289
|
-
}
|
290
|
-
}
|
291
|
-
}
|
292
|
-
},
|
293
189
|
{
|
294
190
|
"description": "a request to determine if Bar can be deployed with all Foo tagged prod, ignoring the verification for Foo version 3.4.5",
|
295
191
|
"providerState": "provider Bar version 4.5.6 has a successful verification for Foo version 1.2.3 tagged prod and a failed verification for version 3.4.5 tagged prod",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pact_broker-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.51.
|
4
|
+
version: 1.51.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Beth Skurrie
|
@@ -380,7 +380,6 @@ files:
|
|
380
380
|
- spec/service_providers/extra_goodies_spec.rb
|
381
381
|
- spec/service_providers/list_environments_spec.rb
|
382
382
|
- spec/service_providers/list_latest_pact_versions_spec.rb.bak
|
383
|
-
- spec/service_providers/pact_broker_client_create_version_spec.rb
|
384
383
|
- spec/service_providers/pact_broker_client_matrix_ignore_spec.rb
|
385
384
|
- spec/service_providers/pact_broker_client_matrix_spec.rb
|
386
385
|
- spec/service_providers/pact_broker_client_pacticipant_version_spec.rb
|
@@ -488,7 +487,6 @@ test_files:
|
|
488
487
|
- spec/service_providers/extra_goodies_spec.rb
|
489
488
|
- spec/service_providers/list_environments_spec.rb
|
490
489
|
- spec/service_providers/list_latest_pact_versions_spec.rb.bak
|
491
|
-
- spec/service_providers/pact_broker_client_create_version_spec.rb
|
492
490
|
- spec/service_providers/pact_broker_client_matrix_ignore_spec.rb
|
493
491
|
- spec/service_providers/pact_broker_client_matrix_spec.rb
|
494
492
|
- spec/service_providers/pact_broker_client_pacticipant_version_spec.rb
|
@@ -1,88 +0,0 @@
|
|
1
|
-
require_relative 'pact_helper'
|
2
|
-
require 'pact_broker/client'
|
3
|
-
require 'pact_broker/client/publish_pacts_the_old_way'
|
4
|
-
|
5
|
-
describe PactBroker::Client::Versions, pact: true do
|
6
|
-
|
7
|
-
include_context "pact broker"
|
8
|
-
|
9
|
-
|
10
|
-
describe "creating a pacticipant version" do
|
11
|
-
before do
|
12
|
-
allow(publish_pacts_the_old_way).to receive(:consumer_names).and_return(["Foo"])
|
13
|
-
allow($stdout).to receive(:puts)
|
14
|
-
end
|
15
|
-
let(:version_path) { "/HAL-REL-PLACEHOLDER-INDEX-PB-PACTICIPANT-VERSION-{pacticipant}-{version}" }
|
16
|
-
let(:version_url) { pact_broker.mock_service_base_url + version_path }
|
17
|
-
let(:number) { "26f353580936ad3b9baddb17b00e84f33c69e7cb" }
|
18
|
-
let(:branch) { "main" }
|
19
|
-
let(:build_url) { "http://my-ci/builds/1" }
|
20
|
-
let(:consumer_version_params) { { number: number, branch: branch, build_url: build_url } }
|
21
|
-
let(:publish_pacts_the_old_way) { PactBroker::Client::PublishPactsTheOldWay.new(pact_broker.mock_service_base_url, ["some-pact.json"], consumer_version_params, {}) }
|
22
|
-
let(:provider_state) { "version #{number} of pacticipant Foo does not exist" }
|
23
|
-
let(:expected_response_status) { 201 }
|
24
|
-
|
25
|
-
subject { publish_pacts_the_old_way.send(:create_consumer_versions) }
|
26
|
-
|
27
|
-
before do
|
28
|
-
pact_broker
|
29
|
-
.given("the pb:pacticipant-version relation exists in the index resource")
|
30
|
-
.upon_receiving("a request for the index resource")
|
31
|
-
.with(
|
32
|
-
method: :get,
|
33
|
-
path: '/',
|
34
|
-
headers: get_request_headers).
|
35
|
-
will_respond_with(
|
36
|
-
status: 200,
|
37
|
-
headers: pact_broker_response_headers,
|
38
|
-
body: {
|
39
|
-
_links: {
|
40
|
-
:'pb:pacticipant-version' => {
|
41
|
-
href: Pact.term(version_url, /http:\/\/.*{pacticipant}.*{version}/)
|
42
|
-
}
|
43
|
-
}
|
44
|
-
}
|
45
|
-
)
|
46
|
-
|
47
|
-
pact_broker
|
48
|
-
.given(provider_state)
|
49
|
-
.upon_receiving("a request to create a pacticipant version")
|
50
|
-
.with(
|
51
|
-
method: :put,
|
52
|
-
path: "/HAL-REL-PLACEHOLDER-INDEX-PB-PACTICIPANT-VERSION-Foo-#{number}",
|
53
|
-
headers: put_request_headers,
|
54
|
-
body: {
|
55
|
-
branch: branch,
|
56
|
-
buildUrl: build_url
|
57
|
-
}).
|
58
|
-
will_respond_with(
|
59
|
-
status: expected_response_status,
|
60
|
-
headers: pact_broker_response_headers,
|
61
|
-
body: {
|
62
|
-
number: number,
|
63
|
-
buildUrl: build_url,
|
64
|
-
_links: {
|
65
|
-
self: {
|
66
|
-
href: Pact.term('http://localhost:1234/some-url', %r{http://.*})
|
67
|
-
}
|
68
|
-
}
|
69
|
-
}
|
70
|
-
)
|
71
|
-
end
|
72
|
-
|
73
|
-
context "when the version does not already exist" do
|
74
|
-
it "returns true" do
|
75
|
-
expect(subject).to be true
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
context "when the version does exist" do
|
80
|
-
let(:provider_state) { "version #{number} of pacticipant Foo does exist" }
|
81
|
-
let(:expected_response_status) { 200 }
|
82
|
-
|
83
|
-
it "returns true" do
|
84
|
-
expect(subject).to be true
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|