pact_broker-client 1.41.0 → 1.46.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/CHANGELOG.md +57 -0
- data/README.md +69 -48
- data/doc/pacts/markdown/Pact Broker Client - Pact Broker.md +79 -102
- data/doc/pacts/markdown/Pact Broker Client - Pactflow.md +94 -0
- data/doc/pacts/markdown/README.md +1 -0
- 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 +40 -5
- data/lib/pact_broker/client/cli/broker.rb +18 -160
- data/lib/pact_broker/client/cli/custom_thor.rb +12 -16
- 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/webhook_commands.rb +122 -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/text_formatter.rb +21 -13
- 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/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/lib/pact_broker/client/webhooks/create.rb +14 -8
- data/pact-broker-client.gemspec +1 -0
- data/script/record-deployments-and-releases.sh +18 -0
- data/script/webhook-commands.sh +12 -0
- data/spec/fixtures/approvals/can_i_deploy_failure_dry_run.approved.txt +7 -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 +62 -2
- data/spec/lib/pact_broker/client/cli/broker_can_i_deploy_spec.rb +17 -4
- 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 +7 -5
- 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 -108
- data/spec/pacts/pact_broker_client-pactflow.json +118 -0
- 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 +1 -1
- data/spec/service_providers/pact_broker_client_register_repository_spec.rb +2 -2
- data/spec/service_providers/pact_helper.rb +15 -10
- data/spec/service_providers/pactflow_webhooks_create_spec.rb +86 -0
- data/spec/service_providers/pacticipants_create_spec.rb +5 -4
- data/spec/service_providers/publish_pacts_spec.rb +3 -1
- data/spec/service_providers/record_deployment_spec.rb +14 -32
- data/spec/service_providers/record_release_spec.rb +132 -0
- data/spec/service_providers/record_undeployment_spec.rb +166 -0
- data/spec/service_providers/webhooks_create_spec.rb +1 -1
- data/spec/spec_helper.rb +15 -2
- data/spec/support/approvals.rb +1 -1
- data/spec/support/shared_context.rb +2 -1
- data/tasks/pact.rake +21 -1
- metadata +82 -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,56 @@
|
|
1
|
+
module PactBroker
|
2
|
+
module Client
|
3
|
+
module StringRefinements
|
4
|
+
refine NilClass do
|
5
|
+
def blank?
|
6
|
+
true
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
refine String do
|
11
|
+
def not_blank?
|
12
|
+
!blank?
|
13
|
+
end
|
14
|
+
|
15
|
+
def blank?
|
16
|
+
self.strip.size == 0
|
17
|
+
end
|
18
|
+
|
19
|
+
# ripped from rubyworks/facets, thank you
|
20
|
+
def snakecase
|
21
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
22
|
+
.gsub(/([a-z\d])([A-Z])/,'\1_\2')
|
23
|
+
.tr('-', '_')
|
24
|
+
.gsub(/\s/, '_')
|
25
|
+
.gsub(/__+/, '_')
|
26
|
+
.downcase
|
27
|
+
end
|
28
|
+
|
29
|
+
# ripped from rubyworks/facets, thank you
|
30
|
+
def camelcase(*separators)
|
31
|
+
case separators.first
|
32
|
+
when Symbol, TrueClass, FalseClass, NilClass
|
33
|
+
first_letter = separators.shift
|
34
|
+
end
|
35
|
+
|
36
|
+
separators = ['_', '\s'] if separators.empty?
|
37
|
+
|
38
|
+
str = self.dup
|
39
|
+
|
40
|
+
separators.each do |s|
|
41
|
+
str = str.gsub(/(?:#{s}+)([a-z])/){ $1.upcase }
|
42
|
+
end
|
43
|
+
|
44
|
+
case first_letter
|
45
|
+
when :upper, true
|
46
|
+
str = str.gsub(/(\A|\s)([a-z])/){ $1 + $2.upcase }
|
47
|
+
when :lower, false
|
48
|
+
str = str.gsub(/(\A|\s)([A-Z])/){ $1 + $2.downcase }
|
49
|
+
end
|
50
|
+
|
51
|
+
str
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# Need Versions class to extend BaseClient until we can remove the old Versions code
|
2
|
+
require 'pact_broker/client/base_client'
|
1
3
|
require 'pact_broker/client/pact_broker_client'
|
2
4
|
require 'pact_broker/client/versions/formatter'
|
3
5
|
|
4
6
|
module PactBroker
|
5
7
|
module Client
|
6
|
-
class Versions
|
8
|
+
class Versions < BaseClient
|
7
9
|
class Describe
|
8
10
|
|
9
11
|
class Result
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# Need Versions class to extend BaseClient until we can remove the old Versions code
|
2
|
+
require 'pact_broker/client/base_client'
|
1
3
|
require 'pact_broker/client/versions/json_formatter'
|
2
4
|
require 'pact_broker/client/versions/text_formatter'
|
3
5
|
|
4
6
|
module PactBroker
|
5
7
|
module Client
|
6
|
-
class Versions
|
8
|
+
class Versions < BaseClient
|
7
9
|
class Formatter
|
8
10
|
def self.call(matrix_lines, format)
|
9
11
|
formatter = case format
|
@@ -1,11 +1,13 @@
|
|
1
|
+
# Need Versions class to extend BaseClient until we can remove the old Versions code
|
2
|
+
require 'pact_broker/client/base_client'
|
1
3
|
require 'table_print'
|
2
4
|
|
3
5
|
module PactBroker
|
4
6
|
module Client
|
5
|
-
class Versions
|
7
|
+
class Versions < BaseClient
|
6
8
|
class JsonFormatter
|
7
|
-
def self.call(
|
8
|
-
JSON.pretty_generate(
|
9
|
+
def self.call(version)
|
10
|
+
JSON.pretty_generate(version)
|
9
11
|
end
|
10
12
|
end
|
11
13
|
end
|
@@ -1,8 +1,10 @@
|
|
1
|
+
# Need Versions class to extend BaseClient until we can remove the old Versions code
|
2
|
+
require 'pact_broker/client/base_client'
|
1
3
|
require 'table_print'
|
2
4
|
|
3
5
|
module PactBroker
|
4
6
|
module Client
|
5
|
-
class Versions
|
7
|
+
class Versions < BaseClient
|
6
8
|
class TextFormatter
|
7
9
|
|
8
10
|
Line = Struct.new(:number, :tags)
|
@@ -3,6 +3,7 @@ require 'pact_broker/client/hal'
|
|
3
3
|
require 'ostruct'
|
4
4
|
require 'json'
|
5
5
|
require 'pact_broker/client/command_result'
|
6
|
+
require "pact_broker/client/backports"
|
6
7
|
|
7
8
|
module PactBroker
|
8
9
|
module Client
|
@@ -61,16 +62,17 @@ module PactBroker
|
|
61
62
|
|
62
63
|
def request_body
|
63
64
|
webhook_request_body = JSON.parse(params.body) rescue params.body
|
65
|
+
request_params = {
|
66
|
+
url: params.url,
|
67
|
+
method: params.http_method,
|
68
|
+
headers: params.headers,
|
69
|
+
body: webhook_request_body,
|
70
|
+
username: params.username,
|
71
|
+
password: params.password
|
72
|
+
}.compact
|
64
73
|
{
|
65
74
|
events: params.events.collect{ | event | { "name" => event }},
|
66
|
-
request:
|
67
|
-
url: params.url,
|
68
|
-
method: params.http_method,
|
69
|
-
headers: params.headers,
|
70
|
-
body: webhook_request_body,
|
71
|
-
username: params.username,
|
72
|
-
password: params.password
|
73
|
-
}
|
75
|
+
request: request_params
|
74
76
|
}.tap { |req| req[:description] = params.description if params.description }
|
75
77
|
end
|
76
78
|
|
@@ -85,6 +87,10 @@ module PactBroker
|
|
85
87
|
body[:provider] = { name: params.provider }
|
86
88
|
end
|
87
89
|
|
90
|
+
if params.team_uuid
|
91
|
+
body[:teamUuid] = params.team_uuid
|
92
|
+
end
|
93
|
+
|
88
94
|
body
|
89
95
|
end
|
90
96
|
|
data/pact-broker-client.gemspec
CHANGED
@@ -34,4 +34,5 @@ Gem::Specification.new do |gem|
|
|
34
34
|
gem.add_development_dependency 'pact', '~> 1.16'
|
35
35
|
gem.add_development_dependency 'pact-support', '~> 1.16'
|
36
36
|
gem.add_development_dependency 'approvals', '>=0.0.24', '<1.0.0'
|
37
|
+
gem.add_development_dependency 'rspec-its', '~> 1.3'
|
37
38
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
export PACT_BROKER_FEATURES=deployments
|
2
|
+
|
3
|
+
bundle exec bin/pact-broker create-or-update-pacticipant --name Foo
|
4
|
+
bundle exec bin/pact-broker create-version-tag --pacticipant Foo --version 2 --tag main --auto-create-version
|
5
|
+
bundle exec bin/pact-broker describe-version --pacticipant Foo --version 2
|
6
|
+
bundle exec bin/pact-broker create-environment --name test
|
7
|
+
bundle exec bin/pact-broker can-i-deploy --pacticipant Foo --version 2 --to-environment test
|
8
|
+
|
9
|
+
bundle exec bin/pact-broker record-deployment --pacticipant Foo --version 2 --environment test
|
10
|
+
bundle exec bin/pact-broker record-deployment --pacticipant Foo --version 2 --environment test --target customer-1
|
11
|
+
bundle exec bin/pact-broker record-deployment --pacticipant Foo --version 2 --environment test --target customer-1
|
12
|
+
|
13
|
+
bundle exec bin/pact-broker record-undeployment --pacticipant Foo --environment test
|
14
|
+
bundle exec bin/pact-broker record-undeployment --pacticipant Foo --environment test
|
15
|
+
bundle exec bin/pact-broker record-undeployment --pacticipant Foo --environment test --target customer-1
|
16
|
+
|
17
|
+
bundle exec bin/pact-broker record-release --pacticipant Foo --version 2 --environment test
|
18
|
+
bundle exec bin/pact-broker record-support-ended --pacticipant Foo --version 2 --environment test
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
bundle exec bin/pact-broker create-webhook \
|
4
|
+
'https://api.github.com/repos/foo/bar/statuses/${pactbroker.consumerVersionNumber}' \
|
5
|
+
-X POST \
|
6
|
+
-H "Content-Type: application/json" \
|
7
|
+
-d '{ "state": "${pactbroker.githubVerificationStatus}", "description": "Pact Verification Tests ${pactbroker.providerVersionTags}", "context": "${pactbroker.providerName}", "target_url": "${pactbroker.verificationResultUrl}" }' \
|
8
|
+
--user username:password \
|
9
|
+
--description "Publish pact verification status to Github" \
|
10
|
+
--contract-published \
|
11
|
+
--provider-verification-published \
|
12
|
+
--team-uuid 4ac05ed8-9e3b-4159-96c0-ad19e3b93658
|
@@ -0,0 +1,7 @@
|
|
1
|
+
[33m[dry-run] [0mComputer says no ¯\_(ツ)_/¯ (but you're ignoring this by enabling dry run)
|
2
|
+
[33m[dry-run] [0m
|
3
|
+
[33m[dry-run] [0mtext matrix
|
4
|
+
[33m[dry-run] [0m
|
5
|
+
[33m[dry-run] [0msome reason
|
6
|
+
[33m[dry-run] [0m
|
7
|
+
[33m[dry-run] [0m[32mDry run enabled - ignoring any failures[0m
|
@@ -0,0 +1,7 @@
|
|
1
|
+
[33m[dry-run] [0mComputer says yes \o/ (and maybe you don't need to enable dry run)
|
2
|
+
[33m[dry-run] [0m
|
3
|
+
[33m[dry-run] [0mtext matrix
|
4
|
+
[33m[dry-run] [0m
|
5
|
+
[33m[dry-run] [0msome reason
|
6
|
+
[33m[dry-run] [0m
|
7
|
+
[33m[dry-run] [0m[32mDry run enabled - ignoring any failures[0m
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'pact_broker/client/cli/broker'
|
2
|
+
|
3
|
+
RSpec.describe "describe-environment" do
|
4
|
+
let(:index_body_hash) do
|
5
|
+
{
|
6
|
+
_links: {
|
7
|
+
"pb:pacticipant" => {
|
8
|
+
href: "http://broker/pacticipants/{pacticipant}"
|
9
|
+
}
|
10
|
+
}
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:pacticipant_body_hash) { JSON.parse(File.read("./spec/support/pacticipant_get.json")) }
|
15
|
+
|
16
|
+
let!(:index_request) do
|
17
|
+
stub_request(:get, "http://broker").to_return(status: 200, body: index_body_hash.to_json, headers: { "Content-Type" => "application/hal+json" } )
|
18
|
+
end
|
19
|
+
|
20
|
+
let!(:pacticipant_request) do
|
21
|
+
stub_request(:get, "http://broker/pacticipants/Foo").to_return(status: 200, body: pacticipant_body_hash.to_json, headers: { "Content-Type" => "application/hal+json" } )
|
22
|
+
end
|
23
|
+
|
24
|
+
let(:parameters) { %w{describe-pacticipant --name Foo --broker-base-url http://broker} }
|
25
|
+
|
26
|
+
subject { capture(:stdout) { PactBroker::Client::CLI::Broker.start(parameters) } }
|
27
|
+
|
28
|
+
it "prints the pacticipant properties" do
|
29
|
+
Approvals.verify(subject, :name => "describe_pacticipant", format: :txt)
|
30
|
+
end
|
31
|
+
end
|
@@ -8,6 +8,7 @@ module PactBroker
|
|
8
8
|
let(:version_selectors) { [{ pacticipant: "Foo", version: "1" }] }
|
9
9
|
let(:matrix_options) { { } }
|
10
10
|
let(:pact_broker_client_options) { { foo: 'bar' } }
|
11
|
+
let(:dry_run) { false }
|
11
12
|
let(:matrix_client) { instance_double('PactBroker::Client::Matrix') }
|
12
13
|
let(:matrix) do
|
13
14
|
instance_double('Matrix::Resource',
|
@@ -23,7 +24,7 @@ module PactBroker
|
|
23
24
|
let(:any_unknown) { unknown_count > 0 }
|
24
25
|
let(:supports_unknown_count) { true }
|
25
26
|
let(:retry_while_unknown) { 0 }
|
26
|
-
let(:options) { { output: 'text', retry_while_unknown: retry_while_unknown, retry_interval: 5 } }
|
27
|
+
let(:options) { { output: 'text', retry_while_unknown: retry_while_unknown, retry_interval: 5, dry_run: dry_run } }
|
27
28
|
let(:notices) { nil }
|
28
29
|
let(:supports_ignore) { true }
|
29
30
|
let(:deployable) { true }
|
@@ -69,6 +70,14 @@ module PactBroker
|
|
69
70
|
expect(subject.message).to include "some notice"
|
70
71
|
end
|
71
72
|
end
|
73
|
+
|
74
|
+
context "when dry_run is enabled" do
|
75
|
+
let(:dry_run) { true }
|
76
|
+
|
77
|
+
it "prefixes each line with [dry-run]" do
|
78
|
+
Approvals.verify(subject.message, :name => "can_i_deploy_success_dry_run", format: :txt)
|
79
|
+
end
|
80
|
+
end
|
72
81
|
end
|
73
82
|
|
74
83
|
context "when the versions are not deployable" do
|
@@ -94,6 +103,18 @@ module PactBroker
|
|
94
103
|
expect(subject.message).to include "some notice"
|
95
104
|
end
|
96
105
|
end
|
106
|
+
|
107
|
+
context "when dry_run is enabled" do
|
108
|
+
let(:dry_run) { true }
|
109
|
+
|
110
|
+
it "returns a success response" do
|
111
|
+
expect(subject.success).to be true
|
112
|
+
end
|
113
|
+
|
114
|
+
it "prefixes each line with [dry-run]" do
|
115
|
+
Approvals.verify(subject.message, :name => "can_i_deploy_failure_dry_run", format: :txt)
|
116
|
+
end
|
117
|
+
end
|
97
118
|
end
|
98
119
|
|
99
120
|
context "when retry_while_unknown is greater than 0" do
|
@@ -135,6 +156,19 @@ module PactBroker
|
|
135
156
|
it "returns a failure message" do
|
136
157
|
expect(subject.message).to match /does not provide a count/
|
137
158
|
end
|
159
|
+
|
160
|
+
context "when dry_run is enabled" do
|
161
|
+
let(:dry_run) { true }
|
162
|
+
|
163
|
+
it "returns a success response" do
|
164
|
+
expect(subject.success).to be true
|
165
|
+
end
|
166
|
+
|
167
|
+
it "returns a failure message" do
|
168
|
+
expect(subject.message).to include "[dry-run]"
|
169
|
+
expect(subject.message).to match /does not provide a count/
|
170
|
+
end
|
171
|
+
end
|
138
172
|
end
|
139
173
|
end
|
140
174
|
|
@@ -169,6 +203,19 @@ module PactBroker
|
|
169
203
|
it "returns a failure message" do
|
170
204
|
expect(subject.message).to include "error text"
|
171
205
|
end
|
206
|
+
|
207
|
+
context "when dry_run is enabled" do
|
208
|
+
let(:dry_run) { true }
|
209
|
+
|
210
|
+
it "returns a success response" do
|
211
|
+
expect(subject.success).to be true
|
212
|
+
end
|
213
|
+
|
214
|
+
it "returns a failure message" do
|
215
|
+
expect(subject.message).to include "[dry-run]"
|
216
|
+
expect(subject.message).to match /error text/
|
217
|
+
end
|
218
|
+
end
|
172
219
|
end
|
173
220
|
|
174
221
|
context "when a StandardError is raised" do
|
@@ -183,7 +230,20 @@ module PactBroker
|
|
183
230
|
end
|
184
231
|
|
185
232
|
it "returns a failure message and backtrace" do
|
186
|
-
expect(subject.message).to include "Error retrieving matrix. StandardError - error text
|
233
|
+
expect(subject.message).to include "Error retrieving matrix. StandardError - error text"
|
234
|
+
end
|
235
|
+
|
236
|
+
context "when dry_run is enabled" do
|
237
|
+
let(:dry_run) { true }
|
238
|
+
|
239
|
+
it "returns a success response" do
|
240
|
+
expect(subject.success).to be true
|
241
|
+
end
|
242
|
+
|
243
|
+
it "returns a failure message" do
|
244
|
+
expect(subject.message).to include "[dry-run]"
|
245
|
+
expect(subject.message).to match /error text/
|
246
|
+
end
|
187
247
|
end
|
188
248
|
end
|
189
249
|
end
|
@@ -25,7 +25,8 @@ module PactBroker
|
|
25
25
|
verbose: 'verbose',
|
26
26
|
retry_while_unknown: 1,
|
27
27
|
retry_interval: 2,
|
28
|
-
limit: 1000
|
28
|
+
limit: 1000,
|
29
|
+
dry_run: false
|
29
30
|
}
|
30
31
|
end
|
31
32
|
|
@@ -37,7 +38,7 @@ module PactBroker
|
|
37
38
|
end
|
38
39
|
|
39
40
|
it "invokes the CanIDeploy service" do
|
40
|
-
expect(CanIDeploy).to receive(:call).with('http://pact-broker', version_selectors, {to_tag: nil, to_environment: nil, limit: 1000, ignore_selectors: []}, {output: 'table', retry_while_unknown: 1, retry_interval: 2}, {verbose: 'verbose'})
|
41
|
+
expect(CanIDeploy).to receive(:call).with('http://pact-broker', version_selectors, { to_tag: nil, to_environment: nil, limit: 1000, ignore_selectors: []}, {output: 'table', retry_while_unknown: 1, retry_interval: 2, dry_run: false}, { pact_broker_base_url: 'http://pact-broker', verbose: 'verbose' })
|
41
42
|
invoke_can_i_deploy
|
42
43
|
end
|
43
44
|
|
@@ -78,7 +79,7 @@ module PactBroker
|
|
78
79
|
end
|
79
80
|
|
80
81
|
it "invokes the CanIDeploy service with the basic auth credentials" do
|
81
|
-
expect(CanIDeploy).to receive(:call).with(anything, anything, anything, anything, {basic_auth: {username: "foo", password: "bar"}, verbose: 'verbose'})
|
82
|
+
expect(CanIDeploy).to receive(:call).with(anything, anything, anything, anything, { pact_broker_base_url: 'http://pact-broker', basic_auth: {username: "foo", password: "bar"}, verbose: 'verbose'})
|
82
83
|
invoke_can_i_deploy
|
83
84
|
end
|
84
85
|
end
|
@@ -89,7 +90,19 @@ module PactBroker
|
|
89
90
|
end
|
90
91
|
|
91
92
|
it "invokes the CanIDeploy service with the basic auth credentials" do
|
92
|
-
expect(CanIDeploy).to receive(:call).with(anything, anything, anything, anything, {token: "some token", verbose: 'verbose'})
|
93
|
+
expect(CanIDeploy).to receive(:call).with(anything, anything, anything, anything, {pact_broker_base_url: 'http://pact-broker', token: "some token", verbose: 'verbose'})
|
94
|
+
invoke_can_i_deploy
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context "when PACT_BROKER_CAN_I_DEPLOY_DRY_RUN=true" do
|
99
|
+
before do
|
100
|
+
allow(ENV).to receive(:[]).and_call_original
|
101
|
+
allow(ENV).to receive(:[]).with("PACT_BROKER_CAN_I_DEPLOY_DRY_RUN").and_return("true")
|
102
|
+
end
|
103
|
+
|
104
|
+
it "invokes the CanIDeploy service with dry_run set to true" do
|
105
|
+
expect(CanIDeploy).to receive(:call).with(anything, anything, anything, hash_including(dry_run: true), anything)
|
93
106
|
invoke_can_i_deploy
|
94
107
|
end
|
95
108
|
end
|