pact_broker-client 1.39.0 → 1.44.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +21 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +52 -0
- data/Gemfile +4 -0
- data/README.md +39 -18
- data/doc/pacts/markdown/Pact Broker Client - Pact Broker.md +79 -280
- data/lib/pact_broker/client/backports.rb +9 -0
- data/lib/pact_broker/client/base_command.rb +95 -0
- data/lib/pact_broker/client/can_i_deploy.rb +20 -3
- data/lib/pact_broker/client/cli/broker.rb +20 -75
- data/lib/pact_broker/client/cli/custom_thor.rb +12 -0
- data/lib/pact_broker/client/cli/deployment_commands.rb +74 -0
- data/lib/pact_broker/client/cli/environment_commands.rb +70 -0
- data/lib/pact_broker/client/cli/pacticipant_commands.rb +53 -0
- data/lib/pact_broker/client/cli/record_deployment_long_desc.txt +0 -55
- data/lib/pact_broker/client/cli/version_selector_options_parser.rb +4 -0
- data/lib/pact_broker/client/colorize_notices.rb +31 -0
- data/lib/pact_broker/client/deployments.rb +4 -0
- data/lib/pact_broker/client/deployments/record_deployment.rb +38 -0
- data/lib/pact_broker/client/deployments/record_release.rb +99 -0
- data/lib/pact_broker/client/deployments/record_undeployment.rb +120 -0
- data/lib/pact_broker/client/describe_text_formatter.rb +23 -0
- data/lib/pact_broker/client/environments.rb +6 -0
- data/lib/pact_broker/client/environments/create_environment.rb +31 -0
- data/lib/pact_broker/client/environments/delete_environment.rb +27 -0
- data/lib/pact_broker/client/environments/describe_environment.rb +26 -0
- data/lib/pact_broker/client/environments/environment_command.rb +66 -0
- data/lib/pact_broker/client/environments/list_environments.rb +30 -0
- data/lib/pact_broker/client/environments/text_formatter.rb +30 -0
- data/lib/pact_broker/client/environments/update_environment.rb +31 -0
- data/lib/pact_broker/client/generate_display_name.rb +27 -0
- data/lib/pact_broker/client/hal/entity.rb +14 -4
- data/lib/pact_broker/client/hal/http_client.rb +8 -2
- data/lib/pact_broker/client/hal/link.rb +8 -0
- data/lib/pact_broker/client/hal_client_methods.rb +1 -3
- data/lib/pact_broker/client/matrix.rb +4 -0
- data/lib/pact_broker/client/matrix/abbreviate_version_number.rb +15 -0
- data/lib/pact_broker/client/matrix/resource.rb +26 -1
- data/lib/pact_broker/client/matrix/text_formatter.rb +28 -17
- data/lib/pact_broker/client/pacticipants.rb +6 -0
- data/lib/pact_broker/client/pacticipants/create.rb +24 -34
- data/lib/pact_broker/client/pacticipants/describe.rb +33 -0
- data/lib/pact_broker/client/pacticipants/list.rb +34 -0
- data/lib/pact_broker/client/pacticipants/text_formatter.rb +41 -0
- data/lib/pact_broker/client/publish_pacts.rb +7 -3
- data/lib/pact_broker/client/string_refinements.rb +56 -0
- data/lib/pact_broker/client/version.rb +1 -1
- data/lib/pact_broker/client/versions.rb +4 -1
- data/lib/pact_broker/client/versions/describe.rb +3 -1
- data/lib/pact_broker/client/versions/formatter.rb +3 -1
- data/lib/pact_broker/client/versions/json_formatter.rb +5 -3
- data/lib/pact_broker/client/versions/text_formatter.rb +3 -1
- data/pact-broker-client.gemspec +2 -0
- data/script/approve-all.sh +6 -0
- data/script/publish-pact.sh +24 -6
- data/script/record-deployments-and-releases.sh +10 -0
- data/spec/fixtures/approvals/can_i_deploy_ignore.approved.txt +13 -0
- data/spec/fixtures/approvals/describe_environment.approved.txt +7 -0
- data/spec/fixtures/approvals/describe_pacticipant.approved.txt +2 -0
- data/spec/fixtures/approvals/list_environments.approved.txt +3 -0
- data/spec/integration/describe_environment_spec.rb +31 -0
- data/spec/lib/pact_broker/client/can_i_deploy_spec.rb +47 -5
- data/spec/lib/pact_broker/client/cli/broker_can_i_deploy_spec.rb +5 -5
- data/spec/lib/pact_broker/client/cli/broker_publish_spec.rb +1 -1
- data/spec/lib/pact_broker/client/cli/broker_run_webhook_commands_spec.rb +3 -3
- data/spec/lib/pact_broker/client/cli/version_selector_options_parser_spec.rb +21 -0
- data/spec/lib/pact_broker/client/deployments/record_deployment_spec.rb +204 -0
- data/spec/lib/pact_broker/client/environments/delete_environment_spec.rb +120 -0
- data/spec/lib/pact_broker/client/environments/describe_environment_spec.rb +89 -0
- data/spec/lib/pact_broker/client/environments/update_environment_spec.rb +167 -0
- data/spec/lib/pact_broker/client/generate_display_name_spec.rb +39 -0
- data/spec/lib/pact_broker/client/hal/entity_spec.rb +2 -2
- data/spec/lib/pact_broker/client/pacticipants/create_spec.rb +2 -2
- data/spec/pacts/pact_broker_client-pact_broker.json +88 -287
- data/spec/service_providers/create_environment_spec.rb +78 -0
- data/spec/service_providers/list_environments_spec.rb +77 -0
- data/spec/service_providers/pact_broker_client_matrix_ignore_spec.rb +98 -0
- data/spec/service_providers/pacticipants_create_spec.rb +5 -4
- data/spec/service_providers/publish_pacts_spec.rb +5 -2
- data/spec/service_providers/record_deployment_spec.rb +17 -36
- data/spec/service_providers/record_release_spec.rb +135 -0
- data/spec/spec_helper.rb +15 -2
- data/spec/support/approvals.rb +26 -0
- data/spec/support/shared_context.rb +6 -2
- data/tasks/pact.rake +19 -1
- metadata +93 -7
- data/lib/pact_broker/client/versions/record_deployment.rb +0 -109
- data/lib/pact_broker/client/versions/record_undeployment.rb +0 -102
- data/spec/lib/pact_broker/client/versions/record_deployment_spec.rb +0 -82
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'service_providers/pact_helper'
|
2
|
+
require 'pact_broker/client/environments/list_environments'
|
3
|
+
|
4
|
+
RSpec.describe "list environments", pact: true, skip: true do
|
5
|
+
include_context "pact broker"
|
6
|
+
include PactBrokerPactHelperMethods
|
7
|
+
|
8
|
+
let(:params) { { output: output } }
|
9
|
+
let(:output) { "text" }
|
10
|
+
let(:pact_broker_client_options) { {} }
|
11
|
+
let(:response_body) do
|
12
|
+
{
|
13
|
+
_embedded: {
|
14
|
+
environments: Pact.each_like(
|
15
|
+
{
|
16
|
+
uuid: "78e85fb2-9df1-48da-817e-c9bea6294e01",
|
17
|
+
name: "test",
|
18
|
+
displayName: "Test",
|
19
|
+
production: false,
|
20
|
+
contacts: [{
|
21
|
+
name: "Foo team",
|
22
|
+
details: {
|
23
|
+
emailAddress: "foo@bar.com"
|
24
|
+
}
|
25
|
+
}]
|
26
|
+
}
|
27
|
+
)
|
28
|
+
}
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
subject { PactBroker::Client::Environments::ListEnvironments.call(params, broker_base_url, pact_broker_client_options) }
|
33
|
+
|
34
|
+
def mock_index
|
35
|
+
pact_broker
|
36
|
+
.given("the pb:environments relation exists in the index resource")
|
37
|
+
.upon_receiving("a request for the index resource")
|
38
|
+
.with(
|
39
|
+
method: "GET",
|
40
|
+
path: '/',
|
41
|
+
headers: get_request_headers).
|
42
|
+
will_respond_with(
|
43
|
+
status: 200,
|
44
|
+
headers: pact_broker_response_headers,
|
45
|
+
body: {
|
46
|
+
_links: {
|
47
|
+
:'pb:environments' => {
|
48
|
+
href: placeholder_url_term("pb:environments")
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
def mock_get_environments
|
56
|
+
pact_broker
|
57
|
+
.given("an environment exists")
|
58
|
+
.upon_receiving("a request to list the environments")
|
59
|
+
.with(
|
60
|
+
method: "GET",
|
61
|
+
path: "/HAL-REL-PLACEHOLDER-PB-ENVIRONMENTS",
|
62
|
+
headers: get_request_headers
|
63
|
+
)
|
64
|
+
.will_respond_with(
|
65
|
+
status: 200,
|
66
|
+
headers: pact_broker_response_headers,
|
67
|
+
body: response_body
|
68
|
+
)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "returns a success result" do
|
72
|
+
mock_index
|
73
|
+
mock_get_environments
|
74
|
+
expect(subject.success).to be true
|
75
|
+
Approvals.verify(subject.message, :name => "list_environments", format: :txt)
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require_relative 'pact_helper'
|
2
|
+
require 'pact_broker/client/can_i_deploy'
|
3
|
+
|
4
|
+
module PactBroker::Client
|
5
|
+
describe Matrix, :pact => true do
|
6
|
+
|
7
|
+
include_context "pact broker"
|
8
|
+
|
9
|
+
describe "can-i-deploy ignoring a pacticipant version" do
|
10
|
+
let(:matrix_response_body) { matrix }
|
11
|
+
let(:matrix) do
|
12
|
+
{
|
13
|
+
"summary" => {
|
14
|
+
"deployable" => true,
|
15
|
+
"ignored" => 1
|
16
|
+
},
|
17
|
+
"notices" => Pact.each_like("text" => "some notice", "type" => "info"),
|
18
|
+
"matrix" => [
|
19
|
+
{
|
20
|
+
"consumer" => {
|
21
|
+
"name" => "Foo",
|
22
|
+
"version" => {
|
23
|
+
"number" => "1.2.3"
|
24
|
+
}
|
25
|
+
},
|
26
|
+
"provider" => {
|
27
|
+
"name" => "Bar",
|
28
|
+
"version" => {
|
29
|
+
"number" => "4.5.6"
|
30
|
+
}
|
31
|
+
},
|
32
|
+
"verificationResult" => {
|
33
|
+
"success" => true,
|
34
|
+
"_links" => {
|
35
|
+
"self" => {
|
36
|
+
"href" => Pact.like("http://result")
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
},{
|
41
|
+
"consumer" => {
|
42
|
+
"name" => "Foo",
|
43
|
+
"version" => {
|
44
|
+
"number" => "3.4.5"
|
45
|
+
}
|
46
|
+
},
|
47
|
+
"provider" => {
|
48
|
+
"name" => "Bar",
|
49
|
+
"version" => {
|
50
|
+
"number" => "4.5.6"
|
51
|
+
}
|
52
|
+
},
|
53
|
+
"verificationResult" => {
|
54
|
+
"success" => false,
|
55
|
+
"_links" => {
|
56
|
+
"self" => {
|
57
|
+
"href" => Pact.like("http://result")
|
58
|
+
}
|
59
|
+
}
|
60
|
+
},
|
61
|
+
"ignored" => true
|
62
|
+
}
|
63
|
+
]
|
64
|
+
}
|
65
|
+
|
66
|
+
end
|
67
|
+
let(:selectors) { [{ pacticipant: "Bar", version: "4.5.6" }, { pacticipant: "Foo", tag: "prod" } ] }
|
68
|
+
let(:matrix_options) do
|
69
|
+
{
|
70
|
+
ignore_selectors: [{ pacticipant: "Foo", version: "3.4.5" }]
|
71
|
+
}
|
72
|
+
end
|
73
|
+
let(:options) { { retry_while_unknown: 0, output: 'table' } }
|
74
|
+
|
75
|
+
before do
|
76
|
+
pact_broker
|
77
|
+
.given("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")
|
78
|
+
.upon_receiving("a request to determine if Bar can be deployed with all Foo tagged prod, ignoring the verification for Foo version 3.4.5")
|
79
|
+
.with(
|
80
|
+
method: :get,
|
81
|
+
path: "/matrix",
|
82
|
+
query: "q%5B%5D%5Bpacticipant%5D=Bar&q%5B%5D%5Bversion%5D=4.5.6&q%5B%5D%5Bpacticipant%5D=Foo&q%5B%5D%5Btag%5D=prod&latestby=cvpv&ignore%5B%5D%5Bpacticipant%5D=Foo&ignore%5B%5D%5Bversion%5D=3.4.5"
|
83
|
+
)
|
84
|
+
.will_respond_with(
|
85
|
+
status: 200,
|
86
|
+
headers: pact_broker_response_headers,
|
87
|
+
body: matrix_response_body
|
88
|
+
)
|
89
|
+
end
|
90
|
+
|
91
|
+
subject { PactBroker::Client::CanIDeploy.call(broker_base_url, selectors, matrix_options, options, {})}
|
92
|
+
|
93
|
+
it 'returns the CLI output' do
|
94
|
+
Approvals.verify(subject.message, :name => "can_i_deploy_ignore", format: :txt)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -54,9 +54,10 @@ RSpec.describe "creating or updating a pacticipant", pact: true do
|
|
54
54
|
}
|
55
55
|
end
|
56
56
|
|
57
|
-
let(:pact_broker_client_options) { {} }
|
57
|
+
let(:pact_broker_client_options) { { pact_broker_base_url: broker_base_url} }
|
58
|
+
let(:options) { {} }
|
58
59
|
|
59
|
-
subject { PactBroker::Client::Pacticipants2::Create.call(params,
|
60
|
+
subject { PactBroker::Client::Pacticipants2::Create.call(params, options, pact_broker_client_options) }
|
60
61
|
|
61
62
|
context "when the pacticipant does not already exist" do
|
62
63
|
before do
|
@@ -81,7 +82,7 @@ RSpec.describe "creating or updating a pacticipant", pact: true do
|
|
81
82
|
it "returns a CommandResult with success = true" do
|
82
83
|
expect(subject).to be_a PactBroker::Client::CommandResult
|
83
84
|
expect(subject.success).to be true
|
84
|
-
expect(subject.message).to
|
85
|
+
expect(subject.message).to include "Pacticipant \"Foo\" created"
|
85
86
|
end
|
86
87
|
end
|
87
88
|
|
@@ -112,7 +113,7 @@ RSpec.describe "creating or updating a pacticipant", pact: true do
|
|
112
113
|
it "returns a CommandResult with success = true" do
|
113
114
|
expect(subject).to be_a PactBroker::Client::CommandResult
|
114
115
|
expect(subject.success).to be true
|
115
|
-
expect(subject.message).to
|
116
|
+
expect(subject.message).to include "Pacticipant \"Foo\" updated"
|
116
117
|
end
|
117
118
|
end
|
118
119
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'pact_broker/client/publish_pacts'
|
2
2
|
require 'service_providers/pact_helper'
|
3
3
|
|
4
|
-
|
4
|
+
publish_contracts_feature_on = ENV.fetch('PACT_BROKER_FEATURES', '').include?("publish_contracts")
|
5
|
+
|
6
|
+
RSpec.describe "publishing contracts", pact: true, skip: !publish_contracts_feature_on do
|
5
7
|
before do
|
6
8
|
allow_any_instance_of(PactBroker::Client::Hal::HttpClient).to receive(:sleep)
|
7
9
|
allow_any_instance_of(PactBroker::Client::Hal::HttpClient).to receive(:default_max_tries).and_return(1)
|
@@ -42,7 +44,8 @@ RSpec.describe "publishing contracts", pact: true do
|
|
42
44
|
specification: "pact",
|
43
45
|
contentType: "application/json",
|
44
46
|
content: expected_content,
|
45
|
-
writeMode: "overwrite"
|
47
|
+
writeMode: "overwrite",
|
48
|
+
onConflict: "overwrite"
|
46
49
|
}
|
47
50
|
]
|
48
51
|
}
|
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'service_providers/pact_helper'
|
2
|
-
require 'pact_broker/client/
|
2
|
+
require 'pact_broker/client/deployments/record_deployment'
|
3
3
|
|
4
|
-
|
4
|
+
deployment_feature_on = ENV.fetch('PACT_BROKER_FEATURES', '').include?("deployments")
|
5
5
|
|
6
|
+
RSpec.describe "recording a deployment", pact: true, skip: !deployment_feature_on do
|
6
7
|
include_context "pact broker"
|
7
8
|
include PactBrokerPactHelperMethods
|
8
9
|
|
@@ -10,19 +11,23 @@ RSpec.describe "recording a deployment", pact: true do
|
|
10
11
|
let(:version_number) { "5556b8149bf8bac76bc30f50a8a2dd4c22c85f30" }
|
11
12
|
let(:environment_name) { "test" }
|
12
13
|
let(:output) { "text" }
|
13
|
-
let(:target) {
|
14
|
+
let(:target) { "blue" }
|
14
15
|
let(:params) do
|
15
16
|
{
|
16
17
|
pacticipant_name: pacticipant_name,
|
17
18
|
version_number: version_number,
|
18
19
|
environment_name: environment_name,
|
19
|
-
target: target
|
20
|
+
target: target
|
21
|
+
}
|
22
|
+
end
|
23
|
+
let(:options) do
|
24
|
+
{
|
20
25
|
output: output
|
21
26
|
}
|
22
27
|
end
|
23
|
-
let(:pact_broker_client_options) { {} }
|
28
|
+
let(:pact_broker_client_options) { { pact_broker_base_url: broker_base_url } }
|
24
29
|
|
25
|
-
subject { PactBroker::Client::
|
30
|
+
subject { PactBroker::Client::Deployments::RecordDeployment.call(params, options, pact_broker_client_options) }
|
26
31
|
|
27
32
|
def mock_index
|
28
33
|
pact_broker
|
@@ -102,18 +107,6 @@ RSpec.describe "recording a deployment", pact: true do
|
|
102
107
|
)
|
103
108
|
end
|
104
109
|
|
105
|
-
def mock_pacticipant_version_not_found
|
106
|
-
pact_broker
|
107
|
-
.given("version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo does not exist")
|
108
|
-
.upon_receiving("a request for a pacticipant version")
|
109
|
-
.with(
|
110
|
-
method: "GET",
|
111
|
-
path: "/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-Foo-5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
|
112
|
-
headers: get_request_headers
|
113
|
-
)
|
114
|
-
.will_respond_with(status: 404)
|
115
|
-
end
|
116
|
-
|
117
110
|
def mock_environments
|
118
111
|
pact_broker
|
119
112
|
.given("an environment with name test exists")
|
@@ -148,14 +141,14 @@ RSpec.describe "recording a deployment", pact: true do
|
|
148
141
|
path: "/HAL-REL-PLACEHOLDER-PB-RECORD-DEPLOYMENT-FOO-5556B8149BF8BAC76BC30F50A8A2DD4C22C85F30-TEST",
|
149
142
|
headers: post_request_headers,
|
150
143
|
body: {
|
151
|
-
|
144
|
+
target: target
|
152
145
|
}
|
153
146
|
)
|
154
147
|
.will_respond_with(
|
155
148
|
status: 201,
|
156
149
|
headers: pact_broker_response_headers,
|
157
150
|
body: {
|
158
|
-
|
151
|
+
target: target
|
159
152
|
}
|
160
153
|
)
|
161
154
|
end
|
@@ -169,30 +162,18 @@ RSpec.describe "recording a deployment", pact: true do
|
|
169
162
|
|
170
163
|
it "returns a success message" do
|
171
164
|
expect(subject.success).to be true
|
172
|
-
expect(subject.message).to
|
165
|
+
expect(subject.message).to include "Recorded deployment of Foo version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 to test environment (target blue) in the Pact Broker."
|
173
166
|
end
|
174
167
|
|
175
168
|
context "when the output is json" do
|
176
169
|
let(:output) { "json" }
|
177
170
|
|
178
171
|
it "returns the JSON payload" do
|
179
|
-
expect(JSON.parse(subject.message)).to eq "
|
172
|
+
expect(JSON.parse(subject.message)).to eq "target" => target
|
180
173
|
end
|
181
174
|
end
|
182
175
|
end
|
183
176
|
|
184
|
-
context "when the specified version does not exist" do
|
185
|
-
before do
|
186
|
-
mock_index
|
187
|
-
mock_pacticipant_version_not_found
|
188
|
-
end
|
189
|
-
|
190
|
-
it "returns an error response" do
|
191
|
-
expect(subject.success).to be false
|
192
|
-
expect(subject.message).to include "Foo version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 not found"
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
177
|
context "when the specified environment is not available for recording a deployment" do
|
197
178
|
before do
|
198
179
|
mock_index
|
@@ -205,14 +186,14 @@ RSpec.describe "recording a deployment", pact: true do
|
|
205
186
|
|
206
187
|
it "returns an error response" do
|
207
188
|
expect(subject.success).to be false
|
208
|
-
expect(subject.message).to
|
189
|
+
expect(subject.message).to include "No environment found"
|
209
190
|
end
|
210
191
|
end
|
211
192
|
|
212
193
|
context "when the specified environment does exist" do
|
213
194
|
it "returns an error response" do
|
214
195
|
expect(subject.success).to be false
|
215
|
-
expect(subject.message).to
|
196
|
+
expect(subject.message).to include "not an available option"
|
216
197
|
end
|
217
198
|
end
|
218
199
|
end
|
@@ -0,0 +1,135 @@
|
|
1
|
+
require 'service_providers/pact_helper'
|
2
|
+
require 'pact_broker/client/deployments/record_deployment'
|
3
|
+
|
4
|
+
deployment_feature_on = ENV.fetch('PACT_BROKER_FEATURES', '').include?("deployments")
|
5
|
+
|
6
|
+
RSpec.describe "recording a release", pact: true, skip: !deployment_feature_on do
|
7
|
+
include_context "pact broker"
|
8
|
+
include PactBrokerPactHelperMethods
|
9
|
+
|
10
|
+
let(:pacticipant_name) { "Foo" }
|
11
|
+
let(:version_number) { "5556b8149bf8bac76bc30f50a8a2dd4c22c85f30" }
|
12
|
+
let(:environment_name) { "test" }
|
13
|
+
let(:output) { "text" }
|
14
|
+
let(:target) { "blue" }
|
15
|
+
let(:params) do
|
16
|
+
{
|
17
|
+
pacticipant_name: pacticipant_name,
|
18
|
+
version_number: version_number,
|
19
|
+
environment_name: environment_name
|
20
|
+
}
|
21
|
+
end
|
22
|
+
let(:options) do
|
23
|
+
{
|
24
|
+
output: output
|
25
|
+
}
|
26
|
+
end
|
27
|
+
let(:pact_broker_client_options) { { pact_broker_base_url: broker_base_url } }
|
28
|
+
|
29
|
+
subject { PactBroker::Client::Deployments::RecordRelease.call(params, options, pact_broker_client_options) }
|
30
|
+
|
31
|
+
def mock_index
|
32
|
+
pact_broker
|
33
|
+
.given("the pb:pacticipant-version and pb:environments relations exist in the index resource")
|
34
|
+
.upon_receiving("a request for the index resource")
|
35
|
+
.with(
|
36
|
+
method: "GET",
|
37
|
+
path: '/',
|
38
|
+
headers: get_request_headers).
|
39
|
+
will_respond_with(
|
40
|
+
status: 200,
|
41
|
+
headers: pact_broker_response_headers,
|
42
|
+
body: {
|
43
|
+
_links: {
|
44
|
+
:'pb:pacticipant-version' => {
|
45
|
+
href: placeholder_url_term("pb:pacticipant-version", ["pacticipant", "version"])
|
46
|
+
},
|
47
|
+
:'pb:environments' => {
|
48
|
+
href: placeholder_url_term("pb:environments")
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
def mock_pacticipant_version_with_test_environment_available_for_release
|
56
|
+
pact_broker
|
57
|
+
.given("version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for release")
|
58
|
+
.upon_receiving("a request for a pacticipant version")
|
59
|
+
.with(
|
60
|
+
method: "GET",
|
61
|
+
path: "/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-Foo-5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
|
62
|
+
headers: get_request_headers
|
63
|
+
)
|
64
|
+
.will_respond_with(
|
65
|
+
status: 200,
|
66
|
+
headers: pact_broker_response_headers,
|
67
|
+
body: {
|
68
|
+
_links: {
|
69
|
+
"pb:record-release" => [
|
70
|
+
{
|
71
|
+
name: "test",
|
72
|
+
href: placeholder_url_term("pb:record-release-#{pacticipant_name}-#{version_number}-#{environment_name}")
|
73
|
+
}
|
74
|
+
]
|
75
|
+
}
|
76
|
+
}
|
77
|
+
)
|
78
|
+
end
|
79
|
+
|
80
|
+
def mock_environments
|
81
|
+
pact_broker
|
82
|
+
.given("an environment with name test exists")
|
83
|
+
.upon_receiving("a request for the environments")
|
84
|
+
.with(
|
85
|
+
method: "GET",
|
86
|
+
path: "/HAL-REL-PLACEHOLDER-PB-ENVIRONMENTS",
|
87
|
+
headers: get_request_headers
|
88
|
+
)
|
89
|
+
.will_respond_with(
|
90
|
+
status: 200,
|
91
|
+
headers: pact_broker_response_headers,
|
92
|
+
body: {
|
93
|
+
_links: {
|
94
|
+
"pb:environments" => [
|
95
|
+
{
|
96
|
+
name: "test",
|
97
|
+
href: Pact.like("href")
|
98
|
+
}
|
99
|
+
]
|
100
|
+
}
|
101
|
+
}
|
102
|
+
)
|
103
|
+
end
|
104
|
+
|
105
|
+
def mock_record_release
|
106
|
+
pact_broker
|
107
|
+
.given("version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for deployment")
|
108
|
+
.upon_receiving("a request to record a release")
|
109
|
+
.with(
|
110
|
+
method: "POST",
|
111
|
+
path: "/HAL-REL-PLACEHOLDER-PB-RECORD-RELEASE-FOO-5556B8149BF8BAC76BC30F50A8A2DD4C22C85F30-TEST",
|
112
|
+
headers: post_request_headers
|
113
|
+
)
|
114
|
+
.will_respond_with(
|
115
|
+
status: 201,
|
116
|
+
headers: pact_broker_response_headers,
|
117
|
+
body: {
|
118
|
+
target: target
|
119
|
+
}
|
120
|
+
)
|
121
|
+
end
|
122
|
+
|
123
|
+
context "when the deployment is recorded successfully" do
|
124
|
+
before do
|
125
|
+
mock_index
|
126
|
+
mock_pacticipant_version_with_test_environment_available_for_release
|
127
|
+
mock_record_release
|
128
|
+
end
|
129
|
+
|
130
|
+
it "returns a success message" do
|
131
|
+
expect(subject.success).to be true
|
132
|
+
expect(subject.message).to include "Recorded release of Foo version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 to test environment in the Pact Broker."
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|