pact_broker-client 1.13.1 → 1.14.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 +4 -4
- data/.gitignore +0 -1
- data/CHANGELOG.md +17 -0
- data/README.md +28 -17
- data/doc/markdown/Pact Broker Client - Pact Broker.md +582 -0
- data/doc/markdown/README.md +3 -0
- data/doc/pacts/markdown/Pact Broker Client - Pact Broker.md +1174 -0
- data/doc/pacts/markdown/README.md +3 -0
- data/example/scripts/README.md +13 -0
- data/example/scripts/deploy-consumer.sh +26 -0
- data/example/scripts/pact.json +67 -0
- data/example/scripts/publish-pact.sh +3 -0
- data/example/scripts/publish-verification.sh +3 -0
- data/example/scripts/verification.json +4 -0
- data/lib/pact_broker/client/base_client.rb +17 -1
- data/lib/pact_broker/client/cli/broker.rb +27 -0
- data/lib/pact_broker/client/cli/can_i_deploy_long_desc.txt +13 -3
- data/lib/pact_broker/client/error.rb +2 -0
- data/lib/pact_broker/client/matrix.rb +0 -2
- data/lib/pact_broker/client/version.rb +1 -1
- data/lib/pact_broker/client/versions.rb +15 -5
- data/lib/pact_broker/client/versions/describe.rb +60 -0
- data/lib/pact_broker/client/versions/formatter.rb +20 -0
- data/lib/pact_broker/client/versions/json_formatter.rb +13 -0
- data/lib/pact_broker/client/versions/text_formatter.rb +31 -0
- data/spec/integration/can_i_deploy_spec.rb +2 -2
- data/spec/integration/create_version_tag_spec.rb +1 -1
- data/spec/lib/pact_broker/client/base_client_spec.rb +28 -0
- data/spec/lib/pact_broker/client/versions/describe_spec.rb +65 -0
- data/spec/pacts/pact_broker_client-pact_broker.json +118 -0
- data/spec/service_providers/pact_broker_client_versions_spec.rb +114 -0
- data/spec/service_providers/pact_helper.rb +1 -0
- metadata +19 -3
@@ -5,7 +5,7 @@ describe "pact-broker create-version-tag" do
|
|
5
5
|
end
|
6
6
|
|
7
7
|
context "when the version is successfully tagged" do
|
8
|
-
subject { `bundle exec bin/pact-broker create-version-tag
|
8
|
+
subject { `bundle exec bin/pact-broker create-version-tag --pacticipant Condor --version 1.3.0 --tag prod --broker-base-url http://localhost:5001` }
|
9
9
|
|
10
10
|
it "returns a success exit code" do
|
11
11
|
subject
|
@@ -3,6 +3,8 @@ module PactBroker
|
|
3
3
|
module Client
|
4
4
|
describe BaseClient do
|
5
5
|
describe '#initialize' do
|
6
|
+
subject { BaseClient.new(base_url: base_url) }
|
7
|
+
|
6
8
|
let(:base_url) { 'http://pact_broker_base_url'}
|
7
9
|
let(:username) { 'pact_repo_username'}
|
8
10
|
let(:password) { 'pact_repo_password'}
|
@@ -45,6 +47,32 @@ module PactBroker
|
|
45
47
|
subject
|
46
48
|
end
|
47
49
|
end
|
50
|
+
|
51
|
+
describe "url_for_relation" do
|
52
|
+
let(:index_body) do
|
53
|
+
{
|
54
|
+
_links: {
|
55
|
+
:'pb:foo-bar' => {
|
56
|
+
href: "http://foo-bar/{name}"
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}.to_json
|
60
|
+
end
|
61
|
+
|
62
|
+
let!(:request) do
|
63
|
+
stub_request(:get, "http://pact_broker_base_url/").to_return(status: 200, body: index_body, headers: { "Content-Type" => "application/json" } )
|
64
|
+
end
|
65
|
+
|
66
|
+
it "retrieves a relation URL from the index" do
|
67
|
+
expect(subject.url_for_relation('pb:foo-bar', name: 'wiffle')).to eq 'http://foo-bar/wiffle'
|
68
|
+
end
|
69
|
+
|
70
|
+
context "when the relation is not found" do
|
71
|
+
it "raises an error" do
|
72
|
+
expect { subject.url_for_relation('pb:not-found', name: 'wiffle') }.to raise_error PactBroker::Client::RelationNotFound, /Could not find relation pb:not-found in index resource/
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
48
76
|
end
|
49
77
|
end
|
50
78
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'pact_broker/client/versions/describe'
|
2
|
+
|
3
|
+
module PactBroker
|
4
|
+
module Client
|
5
|
+
class Versions
|
6
|
+
describe Describe do
|
7
|
+
describe ".call" do
|
8
|
+
|
9
|
+
let(:versions_client) do
|
10
|
+
instance_double('PactBroker::Client::Versions', latest: version_hash)
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:pact_broker_base_url) { 'http://broker' }
|
14
|
+
let(:pact_broker_client_options) { {} }
|
15
|
+
let(:pact_broker_client) { instance_double('PactBroker::Client::PactBrokerClient')}
|
16
|
+
let(:version_hash) do
|
17
|
+
{
|
18
|
+
foo: 'bar'
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
let(:params) do
|
23
|
+
{
|
24
|
+
pacticipant: 'foo',
|
25
|
+
latest: true,
|
26
|
+
tag: 'bar'
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
let(:options) do
|
31
|
+
{
|
32
|
+
output: 'someformat'
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
before do
|
37
|
+
allow(PactBroker::Client::PactBrokerClient).to receive(:new).and_return(pact_broker_client)
|
38
|
+
allow(pact_broker_client).to receive_message_chain(:pacticipants, :versions).and_return(versions_client)
|
39
|
+
allow(Formatter).to receive(:call).and_return('formatted_output')
|
40
|
+
end
|
41
|
+
|
42
|
+
subject { Describe.call(params, options, pact_broker_base_url, pact_broker_client_options) }
|
43
|
+
|
44
|
+
it "invokes the versions client" do
|
45
|
+
expect(versions_client).to receive(:latest).with(params)
|
46
|
+
subject
|
47
|
+
end
|
48
|
+
|
49
|
+
it "formats the output" do
|
50
|
+
expect(Formatter).to receive(:call).with(version_hash, 'someformat')
|
51
|
+
subject
|
52
|
+
end
|
53
|
+
|
54
|
+
it "returns a successful result" do
|
55
|
+
expect(subject.success).to be true
|
56
|
+
end
|
57
|
+
|
58
|
+
it "returns a result with the formatted output as the message" do
|
59
|
+
expect(subject.message).to eq 'formatted_output'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -1090,6 +1090,124 @@
|
|
1090
1090
|
}
|
1091
1091
|
}
|
1092
1092
|
}
|
1093
|
+
},
|
1094
|
+
{
|
1095
|
+
"description": "a request for the index resource",
|
1096
|
+
"providerState": "the pb:latest-version relation exists in the index resource",
|
1097
|
+
"request": {
|
1098
|
+
"method": "get",
|
1099
|
+
"path": "/",
|
1100
|
+
"headers": {
|
1101
|
+
"Accept": "application/json, application/hal+json"
|
1102
|
+
}
|
1103
|
+
},
|
1104
|
+
"response": {
|
1105
|
+
"status": 200,
|
1106
|
+
"headers": {
|
1107
|
+
},
|
1108
|
+
"body": {
|
1109
|
+
"_links": {
|
1110
|
+
"pb:latest-version": {
|
1111
|
+
"href": "http://localhost:1234/HAL-REL-PLACEHOLDER-INDEX-PB-LATEST-VERSION-{pacticipant}"
|
1112
|
+
}
|
1113
|
+
}
|
1114
|
+
},
|
1115
|
+
"matchingRules": {
|
1116
|
+
"$.body._links.pb:latest-version.href": {
|
1117
|
+
"match": "regex",
|
1118
|
+
"regex": "http:\\/\\/.*{pacticipant}"
|
1119
|
+
}
|
1120
|
+
}
|
1121
|
+
}
|
1122
|
+
},
|
1123
|
+
{
|
1124
|
+
"description": "a request to retrieve the latest version of Condor",
|
1125
|
+
"providerState": "'Condor' exists in the pact-broker with the latest version 1.2.3",
|
1126
|
+
"request": {
|
1127
|
+
"method": "get",
|
1128
|
+
"path": "/HAL-REL-PLACEHOLDER-INDEX-PB-LATEST-VERSION-Condor",
|
1129
|
+
"headers": {
|
1130
|
+
"Accept": "application/json, application/hal+json"
|
1131
|
+
}
|
1132
|
+
},
|
1133
|
+
"response": {
|
1134
|
+
"status": 200,
|
1135
|
+
"headers": {
|
1136
|
+
},
|
1137
|
+
"body": {
|
1138
|
+
"number": "1.2.3",
|
1139
|
+
"_links": {
|
1140
|
+
"self": {
|
1141
|
+
"href": "http://localhost:1234/some-url"
|
1142
|
+
}
|
1143
|
+
}
|
1144
|
+
},
|
1145
|
+
"matchingRules": {
|
1146
|
+
"$.body._links.self.href": {
|
1147
|
+
"match": "regex",
|
1148
|
+
"regex": "http:\\/\\/.*"
|
1149
|
+
}
|
1150
|
+
}
|
1151
|
+
}
|
1152
|
+
},
|
1153
|
+
{
|
1154
|
+
"description": "a request for the index resource",
|
1155
|
+
"providerState": "the pb:latest-tagged-version relation exists in the index resource",
|
1156
|
+
"request": {
|
1157
|
+
"method": "get",
|
1158
|
+
"path": "/",
|
1159
|
+
"headers": {
|
1160
|
+
"Accept": "application/json, application/hal+json"
|
1161
|
+
}
|
1162
|
+
},
|
1163
|
+
"response": {
|
1164
|
+
"status": 200,
|
1165
|
+
"headers": {
|
1166
|
+
},
|
1167
|
+
"body": {
|
1168
|
+
"_links": {
|
1169
|
+
"pb:latest-tagged-version": {
|
1170
|
+
"href": "http://localhost:1234/HAL-REL-PLACEHOLDER-INDEX-PB-LATEST-TAGGED-VERSION-{pacticipant}-{tag}"
|
1171
|
+
}
|
1172
|
+
}
|
1173
|
+
},
|
1174
|
+
"matchingRules": {
|
1175
|
+
"$.body._links.pb:latest-tagged-version.href": {
|
1176
|
+
"match": "regex",
|
1177
|
+
"regex": "http:\\/\\/.*{pacticipant}.*{tag}"
|
1178
|
+
}
|
1179
|
+
}
|
1180
|
+
}
|
1181
|
+
},
|
1182
|
+
{
|
1183
|
+
"description": "a request to retrieve the latest 'production' version of Condor",
|
1184
|
+
"providerState": "'Condor' exists in the pact-broker with the latest tagged 'production' version 1.2.3",
|
1185
|
+
"request": {
|
1186
|
+
"method": "get",
|
1187
|
+
"path": "/HAL-REL-PLACEHOLDER-INDEX-PB-LATEST-TAGGED-VERSION-Condor-production",
|
1188
|
+
"headers": {
|
1189
|
+
"Accept": "application/json, application/hal+json"
|
1190
|
+
}
|
1191
|
+
},
|
1192
|
+
"response": {
|
1193
|
+
"status": 200,
|
1194
|
+
"headers": {
|
1195
|
+
},
|
1196
|
+
"body": {
|
1197
|
+
"number": "1.2.3",
|
1198
|
+
"_links": {
|
1199
|
+
"self": {
|
1200
|
+
"href": "http://localhost:1234/some-url"
|
1201
|
+
}
|
1202
|
+
}
|
1203
|
+
},
|
1204
|
+
"matchingRules": {
|
1205
|
+
"$.body._links.self.href": {
|
1206
|
+
"match": "regex",
|
1207
|
+
"regex": "http:\\/\\/.*"
|
1208
|
+
}
|
1209
|
+
}
|
1210
|
+
}
|
1093
1211
|
}
|
1094
1212
|
],
|
1095
1213
|
"metadata": {
|
@@ -0,0 +1,114 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'pact_broker/client'
|
3
|
+
require_relative 'pact_helper'
|
4
|
+
|
5
|
+
describe PactBroker::Client::Versions, pact: true do
|
6
|
+
|
7
|
+
include_context "pact broker"
|
8
|
+
|
9
|
+
let(:get_headers) { { "Accept" => "application/json, application/hal+json" } }
|
10
|
+
|
11
|
+
describe "retrieving the latest pacticipant version" do
|
12
|
+
let(:latest_version_path) { "/HAL-REL-PLACEHOLDER-INDEX-PB-LATEST-VERSION-{pacticipant}" }
|
13
|
+
let(:latest_version_url) { pact_broker.mock_service_base_url + latest_version_path }
|
14
|
+
|
15
|
+
before do
|
16
|
+
pact_broker
|
17
|
+
.given("the pb:latest-version relation exists in the index resource")
|
18
|
+
.upon_receiving("a request for the index resource")
|
19
|
+
.with(
|
20
|
+
method: :get,
|
21
|
+
path: '/',
|
22
|
+
headers: get_headers).
|
23
|
+
will_respond_with(
|
24
|
+
status: 200,
|
25
|
+
headers: pact_broker_response_headers,
|
26
|
+
body: {
|
27
|
+
_links: {
|
28
|
+
:'pb:latest-version' => {
|
29
|
+
href: Pact.term(latest_version_url, /http:\/\/.*{pacticipant}/)
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
)
|
34
|
+
|
35
|
+
pact_broker
|
36
|
+
.given("'Condor' exists in the pact-broker with the latest version 1.2.3")
|
37
|
+
.upon_receiving("a request to retrieve the latest version of Condor")
|
38
|
+
.with(
|
39
|
+
method: :get,
|
40
|
+
path: '/HAL-REL-PLACEHOLDER-INDEX-PB-LATEST-VERSION-Condor',
|
41
|
+
headers: get_headers).
|
42
|
+
will_respond_with(
|
43
|
+
status: 200,
|
44
|
+
headers: pact_broker_response_headers,
|
45
|
+
body: {
|
46
|
+
number: '1.2.3',
|
47
|
+
_links: {
|
48
|
+
self: {
|
49
|
+
href: Pact.term('http://localhost:1234/some-url', %r{http://.*})
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "returns the version hash" do
|
57
|
+
version_hash = pact_broker_client.pacticipants.versions.latest(pacticipant: 'Condor')
|
58
|
+
expect(version_hash[:number]).to eq '1.2.3'
|
59
|
+
expect(version_hash[:_links][:self][:href]).to eq 'http://localhost:1234/some-url'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "retrieving the latest pacticipant version for a tag" do
|
64
|
+
let(:latest_tagged_version_path) { "/HAL-REL-PLACEHOLDER-INDEX-PB-LATEST-TAGGED-VERSION-{pacticipant}-{tag}" }
|
65
|
+
let(:latest_tagged_version_url) { pact_broker.mock_service_base_url + latest_tagged_version_path }
|
66
|
+
|
67
|
+
before do
|
68
|
+
pact_broker
|
69
|
+
.given("the pb:latest-tagged-version relation exists in the index resource")
|
70
|
+
.upon_receiving("a request for the index resource")
|
71
|
+
.with(
|
72
|
+
method: :get,
|
73
|
+
path: '/',
|
74
|
+
headers: get_headers).
|
75
|
+
will_respond_with(
|
76
|
+
status: 200,
|
77
|
+
headers: pact_broker_response_headers,
|
78
|
+
body: {
|
79
|
+
_links: {
|
80
|
+
:'pb:latest-tagged-version' => {
|
81
|
+
href: Pact.term(latest_tagged_version_url, /http:\/\/.*{pacticipant}.*{tag}/)
|
82
|
+
}
|
83
|
+
}
|
84
|
+
}
|
85
|
+
)
|
86
|
+
|
87
|
+
pact_broker
|
88
|
+
.given("'Condor' exists in the pact-broker with the latest tagged 'production' version 1.2.3")
|
89
|
+
.upon_receiving("a request to retrieve the latest 'production' version of Condor")
|
90
|
+
.with(
|
91
|
+
method: :get,
|
92
|
+
path: '/HAL-REL-PLACEHOLDER-INDEX-PB-LATEST-TAGGED-VERSION-Condor-production',
|
93
|
+
headers: get_headers).
|
94
|
+
will_respond_with(
|
95
|
+
status: 200,
|
96
|
+
headers: pact_broker_response_headers,
|
97
|
+
body: {
|
98
|
+
number: '1.2.3',
|
99
|
+
_links: {
|
100
|
+
self: {
|
101
|
+
href: Pact.term('http://localhost:1234/some-url', %r{http://.*})
|
102
|
+
}
|
103
|
+
}
|
104
|
+
}
|
105
|
+
)
|
106
|
+
end
|
107
|
+
|
108
|
+
it "returns the version hash" do
|
109
|
+
version_hash = pact_broker_client.pacticipants.versions.latest(pacticipant: 'Condor', tag: 'production')
|
110
|
+
expect(version_hash[:number]).to eq '1.2.3'
|
111
|
+
expect(version_hash[:_links][:self][:href]).to eq 'http://localhost:1234/some-url'
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
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.
|
4
|
+
version: 1.14.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:
|
11
|
+
date: 2018-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -172,6 +172,14 @@ files:
|
|
172
172
|
- ci.sh
|
173
173
|
- doc/markdown/Pact Broker Client - Pact Broker.md
|
174
174
|
- doc/markdown/README.md
|
175
|
+
- doc/pacts/markdown/Pact Broker Client - Pact Broker.md
|
176
|
+
- doc/pacts/markdown/README.md
|
177
|
+
- example/scripts/README.md
|
178
|
+
- example/scripts/deploy-consumer.sh
|
179
|
+
- example/scripts/pact.json
|
180
|
+
- example/scripts/publish-pact.sh
|
181
|
+
- example/scripts/publish-verification.sh
|
182
|
+
- example/scripts/verification.json
|
175
183
|
- lib/pact_broker/client.rb
|
176
184
|
- lib/pact_broker/client/base_client.rb
|
177
185
|
- lib/pact_broker/client/can_i_deploy.rb
|
@@ -198,6 +206,10 @@ files:
|
|
198
206
|
- lib/pact_broker/client/tasks/publication_task.rb
|
199
207
|
- lib/pact_broker/client/version.rb
|
200
208
|
- lib/pact_broker/client/versions.rb
|
209
|
+
- lib/pact_broker/client/versions/describe.rb
|
210
|
+
- lib/pact_broker/client/versions/formatter.rb
|
211
|
+
- lib/pact_broker/client/versions/json_formatter.rb
|
212
|
+
- lib/pact_broker/client/versions/text_formatter.rb
|
201
213
|
- lib/pact_broker_client.rb
|
202
214
|
- pact-broker-client.gemspec
|
203
215
|
- script/generate-cli-usage.sh
|
@@ -218,6 +230,7 @@ files:
|
|
218
230
|
- spec/lib/pact_broker/client/pacticipants_spec.rb
|
219
231
|
- spec/lib/pact_broker/client/publish_pacts_spec.rb
|
220
232
|
- spec/lib/pact_broker/client/tasks/publication_task_spec.rb
|
233
|
+
- spec/lib/pact_broker/client/versions/describe_spec.rb
|
221
234
|
- spec/lib/pact_broker/client/versions_spec.rb
|
222
235
|
- spec/pacts/pact_broker_client-pact_broker.json
|
223
236
|
- spec/service_providers/extra_goodies_spec.rb
|
@@ -228,6 +241,7 @@ files:
|
|
228
241
|
- spec/service_providers/pact_broker_client_retrieve_all_pacts_for_provider_spec.rb
|
229
242
|
- spec/service_providers/pact_broker_client_retrive_pact_spec.rb
|
230
243
|
- spec/service_providers/pact_broker_client_tags_spec.rb
|
244
|
+
- spec/service_providers/pact_broker_client_versions_spec.rb
|
231
245
|
- spec/service_providers/pact_helper.rb
|
232
246
|
- spec/spec_helper.rb
|
233
247
|
- spec/support/cli_test_pacts/bar.json
|
@@ -261,7 +275,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
261
275
|
version: '0'
|
262
276
|
requirements: []
|
263
277
|
rubyforge_project:
|
264
|
-
rubygems_version: 2.
|
278
|
+
rubygems_version: 2.6.11
|
265
279
|
signing_key:
|
266
280
|
specification_version: 4
|
267
281
|
summary: See description
|
@@ -281,6 +295,7 @@ test_files:
|
|
281
295
|
- spec/lib/pact_broker/client/pacticipants_spec.rb
|
282
296
|
- spec/lib/pact_broker/client/publish_pacts_spec.rb
|
283
297
|
- spec/lib/pact_broker/client/tasks/publication_task_spec.rb
|
298
|
+
- spec/lib/pact_broker/client/versions/describe_spec.rb
|
284
299
|
- spec/lib/pact_broker/client/versions_spec.rb
|
285
300
|
- spec/pacts/pact_broker_client-pact_broker.json
|
286
301
|
- spec/service_providers/extra_goodies_spec.rb
|
@@ -291,6 +306,7 @@ test_files:
|
|
291
306
|
- spec/service_providers/pact_broker_client_retrieve_all_pacts_for_provider_spec.rb
|
292
307
|
- spec/service_providers/pact_broker_client_retrive_pact_spec.rb
|
293
308
|
- spec/service_providers/pact_broker_client_tags_spec.rb
|
309
|
+
- spec/service_providers/pact_broker_client_versions_spec.rb
|
294
310
|
- spec/service_providers/pact_helper.rb
|
295
311
|
- spec/spec_helper.rb
|
296
312
|
- spec/support/cli_test_pacts/bar.json
|