pact_broker-client 1.40.0 → 1.45.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 +57 -0
- data/Gemfile +4 -0
- data/README.md +39 -22
- 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 +98 -0
- data/lib/pact_broker/client/can_i_deploy.rb +57 -5
- data/lib/pact_broker/client/cli/broker.rb +23 -76
- data/lib/pact_broker/client/cli/custom_thor.rb +12 -0
- data/lib/pact_broker/client/cli/deployment_commands.rb +94 -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_support_ended.rb +103 -0
- data/lib/pact_broker/client/deployments/record_undeployment.rb +127 -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 +31 -6
- 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 +6 -2
- 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 +12 -9
- data/script/record-deployments-and-releases.sh +18 -0
- data/spec/fixtures/approvals/can_i_deploy_failure_dry_run.approved.txt +7 -0
- data/spec/fixtures/approvals/can_i_deploy_ignore.approved.txt +13 -0
- data/spec/fixtures/approvals/can_i_deploy_success_dry_run.approved.txt +7 -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 +109 -7
- data/spec/lib/pact_broker/client/cli/broker_can_i_deploy_spec.rb +19 -6
- 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/deployments/record_support_ended_spec.rb +208 -0
- data/spec/lib/pact_broker/client/deployments/record_undeployment_spec.rb +219 -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/pact_broker_client_register_repository_spec.rb +2 -2
- 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 +132 -0
- data/spec/service_providers/record_undeployment_spec.rb +166 -0
- data/spec/spec_helper.rb +15 -2
- data/spec/support/approvals.rb +26 -0
- data/spec/support/shared_context.rb +8 -3
- data/tasks/pact.rake +21 -1
- metadata +104 -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,78 @@
|
|
1
|
+
require 'service_providers/pact_helper'
|
2
|
+
require 'pact_broker/client/environments/create_environment'
|
3
|
+
|
4
|
+
RSpec.describe "create an environment", pact: true, skip: true do
|
5
|
+
include_context "pact broker"
|
6
|
+
include PactBrokerPactHelperMethods
|
7
|
+
|
8
|
+
let(:params) do
|
9
|
+
{
|
10
|
+
name: "test",
|
11
|
+
display_name: "Test",
|
12
|
+
production: false,
|
13
|
+
contact_name: "Foo team",
|
14
|
+
contact_email_address: "foo@bar.com"
|
15
|
+
|
16
|
+
}
|
17
|
+
end
|
18
|
+
let(:pact_broker_client_options) { {} }
|
19
|
+
let(:request_body) do
|
20
|
+
{
|
21
|
+
name: "test",
|
22
|
+
displayName: "Test",
|
23
|
+
production: false,
|
24
|
+
contacts: [{
|
25
|
+
name: "Foo team",
|
26
|
+
details: {
|
27
|
+
emailAddress: "foo@bar.com"
|
28
|
+
}
|
29
|
+
}]
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
subject { PactBroker::Client::Environments::CreateEnvironment.call(params, broker_base_url, pact_broker_client_options) }
|
34
|
+
|
35
|
+
def mock_index
|
36
|
+
pact_broker
|
37
|
+
.given("the pb:environments relation exists in the index resource")
|
38
|
+
.upon_receiving("a request for the index resource")
|
39
|
+
.with(
|
40
|
+
method: "GET",
|
41
|
+
path: '/',
|
42
|
+
headers: get_request_headers).
|
43
|
+
will_respond_with(
|
44
|
+
status: 200,
|
45
|
+
headers: pact_broker_response_headers,
|
46
|
+
body: {
|
47
|
+
_links: {
|
48
|
+
:'pb:environments' => {
|
49
|
+
href: placeholder_url_term("pb:environments")
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
def mock_environment_creation_request
|
57
|
+
pact_broker
|
58
|
+
.upon_receiving("a request to create an environment")
|
59
|
+
.with(
|
60
|
+
method: "POST",
|
61
|
+
path: "/HAL-REL-PLACEHOLDER-PB-ENVIRONMENTS",
|
62
|
+
headers: post_request_headers,
|
63
|
+
body: request_body
|
64
|
+
)
|
65
|
+
.will_respond_with(
|
66
|
+
status: 201,
|
67
|
+
headers: pact_broker_response_headers,
|
68
|
+
body: request_body.merge("uuid" => Pact.like("ffe683ef-dcd7-4e4f-877d-f6eb3db8e86e"))
|
69
|
+
)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "returns a success result" do
|
73
|
+
mock_index
|
74
|
+
mock_environment_creation_request
|
75
|
+
expect(subject.success).to be true
|
76
|
+
expect(subject.message).to include "Created test environment in the Pact Broker with UUID ffe683ef-dcd7-4e4f-877d-f6eb3db8e86e"
|
77
|
+
end
|
78
|
+
end
|
@@ -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
|
@@ -14,7 +14,7 @@ module PactBroker::Client
|
|
14
14
|
with(
|
15
15
|
method: :patch,
|
16
16
|
path: '/pacticipants/Pricing%20Service',
|
17
|
-
headers:
|
17
|
+
headers: old_patch_request_headers,
|
18
18
|
body: {repository_url: repository_url} ).
|
19
19
|
will_respond_with(
|
20
20
|
status: 201,
|
@@ -33,7 +33,7 @@ module PactBroker::Client
|
|
33
33
|
with(
|
34
34
|
method: :patch,
|
35
35
|
path: '/pacticipants/Pricing%20Service',
|
36
|
-
headers:
|
36
|
+
headers: old_patch_request_headers,
|
37
37
|
body: { repository_url: repository_url }).
|
38
38
|
will_respond_with(
|
39
39
|
status: 200,
|
@@ -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
|