pact_broker-client 1.75.3 → 1.75.4

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.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/lib/pact_broker/client/version.rb +1 -1
  4. metadata +5 -216
  5. data/.github/workflows/test.yml +0 -59
  6. data/.rspec +0 -3
  7. data/lib/pact_broker/client/pacts/list_latest_versions.rb +0 -66
  8. data/lib/pact_broker/client/webhooks/test.rb +0 -16
  9. data/pact-broker-client.gemspec +0 -31
  10. data/spec/fixtures/MyConsumer-MyProvider (1).json +0 -37
  11. data/spec/fixtures/MyConsumer-MyProvider.json +0 -37
  12. data/spec/fixtures/approvals/can_i_deploy_failure_dry_run.approved.txt +0 -7
  13. data/spec/fixtures/approvals/can_i_deploy_ignore.approved.txt +0 -13
  14. data/spec/fixtures/approvals/can_i_deploy_success_dry_run.approved.txt +0 -7
  15. data/spec/fixtures/approvals/describe_environment.approved.txt +0 -7
  16. data/spec/fixtures/approvals/describe_pacticipant.approved.txt +0 -2
  17. data/spec/fixtures/approvals/list_environments.approved.txt +0 -3
  18. data/spec/fixtures/approvals/publish_provider_contract.approved.txt +0 -2
  19. data/spec/fixtures/certificates/ca_cert.pem +0 -19
  20. data/spec/fixtures/certificates/ca_cert.srl +0 -1
  21. data/spec/fixtures/certificates/ca_key.pem +0 -28
  22. data/spec/fixtures/certificates/client_cert.pem +0 -17
  23. data/spec/fixtures/certificates/key.pem +0 -28
  24. data/spec/fixtures/certificates/server.csr +0 -15
  25. data/spec/fixtures/certificates/unsigned_cert.pem +0 -19
  26. data/spec/fixtures/certificates/unsigned_key.pem +0 -28
  27. data/spec/fixtures/foo-bar.json +0 -31
  28. data/spec/integration/can_i_deploy_spec.rb +0 -24
  29. data/spec/integration/can_i_merge_spec.rb +0 -44
  30. data/spec/integration/create_version_tag_spec.rb +0 -20
  31. data/spec/integration/describe_environment_spec.rb +0 -31
  32. data/spec/integration/publish_provider_contract_spec.rb +0 -53
  33. data/spec/integration/unknown_options_spec.rb +0 -39
  34. data/spec/lib/pact_broker/client/base_client_spec.rb +0 -182
  35. data/spec/lib/pact_broker/client/branches/delete_branch_spec.rb +0 -103
  36. data/spec/lib/pact_broker/client/can_i_deploy_spec.rb +0 -250
  37. data/spec/lib/pact_broker/client/cli/broker_can_i_deploy_spec.rb +0 -196
  38. data/spec/lib/pact_broker/client/cli/broker_create_or_update_webhook_spec.rb +0 -23
  39. data/spec/lib/pact_broker/client/cli/broker_create_webhook_spec.rb +0 -23
  40. data/spec/lib/pact_broker/client/cli/broker_publish_spec.rb +0 -327
  41. data/spec/lib/pact_broker/client/cli/broker_run_webhook_commands_spec.rb +0 -287
  42. data/spec/lib/pact_broker/client/cli/custom_thor_spec.rb +0 -174
  43. data/spec/lib/pact_broker/client/cli/version_selector_options_parser_spec.rb +0 -97
  44. data/spec/lib/pact_broker/client/deployments/record_deployment_spec.rb +0 -224
  45. data/spec/lib/pact_broker/client/deployments/record_support_ended_spec.rb +0 -208
  46. data/spec/lib/pact_broker/client/deployments/record_undeployment_spec.rb +0 -227
  47. data/spec/lib/pact_broker/client/environments/delete_environment_spec.rb +0 -120
  48. data/spec/lib/pact_broker/client/environments/describe_environment_spec.rb +0 -89
  49. data/spec/lib/pact_broker/client/environments/update_environment_spec.rb +0 -167
  50. data/spec/lib/pact_broker/client/generate_display_name_spec.rb +0 -39
  51. data/spec/lib/pact_broker/client/git_spec.rb +0 -159
  52. data/spec/lib/pact_broker/client/hal/authorization_header_redactor_spec.rb +0 -17
  53. data/spec/lib/pact_broker/client/hal/entity_spec.rb +0 -149
  54. data/spec/lib/pact_broker/client/hal/http_client_spec.rb +0 -238
  55. data/spec/lib/pact_broker/client/hal/link_spec.rb +0 -127
  56. data/spec/lib/pact_broker/client/matrix/abbreviate_version_number_spec.rb +0 -42
  57. data/spec/lib/pact_broker/client/matrix/resource_spec.rb +0 -70
  58. data/spec/lib/pact_broker/client/matrix/text_formatter_spec.rb +0 -63
  59. data/spec/lib/pact_broker/client/matrix_spec.rb +0 -17
  60. data/spec/lib/pact_broker/client/merge_pacts_spec.rb +0 -198
  61. data/spec/lib/pact_broker/client/pact_broker_client_spec.rb +0 -47
  62. data/spec/lib/pact_broker/client/pacticipants/create_spec.rb +0 -31
  63. data/spec/lib/pact_broker/client/pacticipants_spec.rb +0 -18
  64. data/spec/lib/pact_broker/client/publish_pacts_the_old_way_spec.rb +0 -272
  65. data/spec/lib/pact_broker/client/retry_spec.rb +0 -119
  66. data/spec/lib/pact_broker/client/tasks/publication_task_spec.rb +0 -231
  67. data/spec/lib/pact_broker/client/versions/create_spec.rb +0 -174
  68. data/spec/lib/pact_broker/client/versions/describe_spec.rb +0 -64
  69. data/spec/lib/pact_broker/client/versions_spec.rb +0 -34
  70. data/spec/lib/pact_broker/client/webhooks/create_spec.rb +0 -99
  71. data/spec/lib/pactflow/client/provider_contracts/publish_spec.rb +0 -179
  72. data/spec/pacts/pact_broker_client-pact_broker.json +0 -2969
  73. data/spec/pacts/pact_broker_client-pactflow.json +0 -288
  74. data/spec/readme_spec.rb +0 -16
  75. data/spec/service_providers/create_environment_spec.rb +0 -78
  76. data/spec/service_providers/delete_branch_spec.rb +0 -68
  77. data/spec/service_providers/extra_goodies_spec.rb +0 -108
  78. data/spec/service_providers/list_environments_spec.rb +0 -77
  79. data/spec/service_providers/list_latest_pact_versions_spec.rb.bak +0 -44
  80. data/spec/service_providers/pact_broker_client_matrix_ignore_spec.rb +0 -98
  81. data/spec/service_providers/pact_broker_client_matrix_spec.rb +0 -292
  82. data/spec/service_providers/pact_broker_client_pacticipant_version_spec.rb +0 -56
  83. data/spec/service_providers/pact_broker_client_publish_spec.rb +0 -135
  84. data/spec/service_providers/pact_broker_client_register_repository_spec.rb +0 -49
  85. data/spec/service_providers/pact_broker_client_retrieve_all_pacts_for_provider_spec.rb +0 -53
  86. data/spec/service_providers/pact_broker_client_retrieve_pact_spec.rb +0 -109
  87. data/spec/service_providers/pact_broker_client_tags_spec.rb +0 -101
  88. data/spec/service_providers/pact_broker_client_versions_spec.rb +0 -113
  89. data/spec/service_providers/pact_helper.rb +0 -136
  90. data/spec/service_providers/pactflow_publish_provider_contract_spec.rb +0 -137
  91. data/spec/service_providers/pactflow_publish_provider_contract_the_old_way_spec.rb +0 -129
  92. data/spec/service_providers/pactflow_webhooks_create_spec.rb +0 -86
  93. data/spec/service_providers/pacticipants_create_spec.rb +0 -119
  94. data/spec/service_providers/publish_pacts_spec.rb +0 -114
  95. data/spec/service_providers/record_deployment_spec.rb +0 -199
  96. data/spec/service_providers/record_release_spec.rb +0 -130
  97. data/spec/service_providers/record_undeployment_spec.rb +0 -164
  98. data/spec/service_providers/webhooks_create_spec.rb +0 -391
  99. data/spec/spec_helper.rb +0 -68
  100. data/spec/support/approvals.rb +0 -26
  101. data/spec/support/cli_test_pacts/bar.json +0 -0
  102. data/spec/support/cli_test_pacts/foo.json +0 -0
  103. data/spec/support/latest_pacts_for_provider.json +0 -15
  104. data/spec/support/matrix.json +0 -35
  105. data/spec/support/matrix.txt +0 -3
  106. data/spec/support/matrix_error.txt +0 -3
  107. data/spec/support/matrix_with_results.txt +0 -10
  108. data/spec/support/pacticipant_get.json +0 -18
  109. data/spec/support/pacticipants_list.json +0 -26
  110. data/spec/support/pacts_latest_list.json +0 -41
  111. data/spec/support/shared_context.rb +0 -25
  112. data/spec/support/ssl_server.rb +0 -42
@@ -1,103 +0,0 @@
1
- require "pact_broker/client/branches/delete_branch"
2
-
3
- module PactBroker
4
- module Client
5
- module Branches
6
- describe DeleteBranch do
7
- before do
8
- allow_any_instance_of(PactBroker::Client::Hal::HttpClient).to receive(:sleep)
9
- allow_any_instance_of(PactBroker::Client::Hal::HttpClient).to receive(:default_max_tries).and_return(1)
10
- end
11
-
12
- let(:params) do
13
- {
14
- pacticipant: "Foo",
15
- branch: "main",
16
- error_when_not_found: error_when_not_found
17
- }
18
- end
19
- let(:options) do
20
- {
21
- verbose: verbose
22
- }
23
- end
24
- let(:error_when_not_found) { true }
25
- let(:pact_broker_base_url) { "http://example.org" }
26
- let(:pact_broker_client_options) { { pact_broker_base_url: pact_broker_base_url } }
27
- let(:response_headers) { { "Content-Type" => "application/hal+json"} }
28
- let(:verbose) { false }
29
-
30
- before do
31
- stub_request(:get, "http://example.org/").to_return(status: 200, body: index_response_body, headers: response_headers)
32
- stub_request(:delete, "http://example.org/pacticipants/Foo/branches/main").to_return(status: delete_response_status, body: delete_response_body, headers: response_headers)
33
- end
34
- let(:delete_response_status) { 200 }
35
-
36
- let(:index_response_body) do
37
- {
38
- "_links" => {
39
- "pb:pacticipant-branch" => {
40
- "href" => "http://example.org/pacticipants/{pacticipant}/branches/{branch}"
41
- }
42
- }
43
- }.to_json
44
- end
45
-
46
- let(:delete_response_body) do
47
- { "some" => "error message" }.to_json
48
- end
49
-
50
- subject { DeleteBranch.call(params, options, pact_broker_client_options) }
51
-
52
- context "when the branch is deleted" do
53
- it "returns a success result" do
54
- expect(subject.success).to be true
55
- expect(subject.message).to include "Successfully deleted branch main of pacticipant Foo"
56
- end
57
- end
58
-
59
- context "when there is a non-404 error" do
60
- let(:delete_response_status) { 403 }
61
-
62
- it "returns an error result with the response body" do
63
- expect(subject.success).to be false
64
- expect(subject.message).to include "error message"
65
- end
66
- end
67
-
68
- context "when the branch is not found" do
69
- let(:delete_response_status) { 404 }
70
-
71
- context "when error_when_not_found is true" do
72
- it "returns an error" do
73
- expect(subject.success).to be false
74
- expect(subject.message).to include "Could not delete branch main of pacticipant Foo as it was not found"
75
- end
76
- end
77
-
78
- context "when error_when_not_found is false" do
79
- let(:error_when_not_found) { false }
80
-
81
- it "return a success" do
82
- expect(subject.success).to be true
83
- expect(subject.message).to include "Branch main of pacticipant Foo not found"
84
- end
85
- end
86
- end
87
-
88
- context "when deleting branches is not supported" do
89
- let(:index_response_body) do
90
- {
91
- _links: {}
92
- }.to_json
93
- end
94
-
95
- it "returns an error" do
96
- expect(subject.success).to be false
97
- expect(subject.message).to include "not support"
98
- end
99
- end
100
- end
101
- end
102
- end
103
- end
@@ -1,250 +0,0 @@
1
- require 'pact_broker/client/can_i_deploy'
2
- require 'pact_broker/client/matrix/resource'
3
-
4
- module PactBroker
5
- module Client
6
- describe CanIDeploy do
7
- let(:pact_broker_base_url) { 'http://example.org' }
8
- let(:version_selectors) { [{ pacticipant: "Foo", version: "1" }] }
9
- let(:matrix_options) { { } }
10
- let(:pact_broker_client_options) { { pact_broker_base_url: pact_broker_base_url, foo: 'bar' } }
11
- let(:dry_run) { false }
12
- let(:matrix_client) { instance_double('PactBroker::Client::Matrix') }
13
- let(:matrix) do
14
- instance_double('Matrix::Resource',
15
- deployable?: deployable,
16
- reason: 'some reason',
17
- any_unknown?: any_unknown,
18
- supports_unknown_count?: supports_unknown_count,
19
- supports_ignore?: supports_ignore,
20
- unknown_count: unknown_count,
21
- notices: notices)
22
- end
23
- let(:unknown_count) { 0 }
24
- let(:any_unknown) { unknown_count > 0 }
25
- let(:supports_unknown_count) { true }
26
- let(:retry_while_unknown) { 0 }
27
- let(:options) { { output: 'text', retry_while_unknown: retry_while_unknown, retry_interval: 5, dry_run: dry_run } }
28
- let(:notices) { nil }
29
- let(:supports_ignore) { true }
30
- let(:deployable) { true }
31
-
32
-
33
- before do
34
- allow(PactBroker::Client::Matrix::Query).to receive(:call).and_return(matrix)
35
- allow(Matrix::Formatter).to receive(:call).and_return('text matrix')
36
- end
37
-
38
- subject { CanIDeploy.call(version_selectors, matrix_options, options, pact_broker_client_options) }
39
-
40
- it "retrieves the matrix from the pact broker" do
41
- expect(PactBroker::Client::Matrix::Query).to receive(:call).with({ selectors: version_selectors, matrix_options: matrix_options }, options, pact_broker_client_options)
42
- subject
43
- end
44
-
45
- it "creates a text table out of the matrix" do
46
- expect(Matrix::Formatter).to receive(:call).with(matrix, 'text')
47
- subject
48
- end
49
-
50
- context "when the versions are deployable" do
51
- it "returns a success response" do
52
- expect(subject.success).to be true
53
- end
54
-
55
- it "returns a success message with the text table" do
56
- expect(subject.message).to include "Computer says yes"
57
- expect(subject.message).to include "\n\ntext matrix"
58
- end
59
-
60
- it "returns a success reason" do
61
- expect(subject.message).to include "some reason"
62
- end
63
-
64
- context "when there are notices" do
65
- let(:notices) { [Notice.new(text: "some notice", type: "info")] }
66
-
67
- it "returns the notices instead of the reason" do
68
- expect(subject.message).to_not include "some reason"
69
- expect(subject.message).to include "some notice"
70
- end
71
- end
72
-
73
- context "when dry_run is enabled" do
74
- let(:dry_run) { true }
75
-
76
- it "prefixes each line with [dry-run]" do
77
- Approvals.verify(subject.message, :name => "can_i_deploy_success_dry_run", format: :txt)
78
- end
79
- end
80
- end
81
-
82
- context "when the versions are not deployable" do
83
- let(:matrix) { instance_double('Matrix::Resource', deployable?: false, reason: 'some reason', any_unknown?: false, notices: notices) }
84
-
85
- it "returns a failure response" do
86
- expect(subject.success).to be false
87
- end
88
-
89
- it "returns a failure message" do
90
- expect(subject.message).to include "Computer says no"
91
- end
92
-
93
- it "returns a failure reason" do
94
- expect(subject.message).to include "some reason"
95
- end
96
-
97
- context "when there are notices" do
98
- let(:notices) { [Notice.new(text: "some notice", type: "info")] }
99
-
100
- it "returns the notices instead of the reason" do
101
- expect(subject.message).to_not include "some reason"
102
- expect(subject.message).to include "some notice"
103
- end
104
- end
105
-
106
- context "when dry_run is enabled" do
107
- let(:dry_run) { true }
108
-
109
- it "returns a success response" do
110
- expect(subject.success).to be true
111
- end
112
-
113
- it "prefixes each line with [dry-run]" do
114
- Approvals.verify(subject.message, :name => "can_i_deploy_failure_dry_run", format: :txt)
115
- end
116
- end
117
- end
118
-
119
- context "when retry_while_unknown is greater than 0" do
120
- let(:retry_while_unknown) { 1 }
121
-
122
- context "when any_unknown? is false" do
123
- it "does not retry the request" do
124
- expect(Retry).to_not receive(:until_truthy_or_max_times)
125
- subject
126
- end
127
- end
128
-
129
- context "when any_unknown? is true" do
130
- before do
131
- allow($stderr).to receive(:puts)
132
- allow(Retry).to receive(:until_truthy_or_max_times)
133
- end
134
-
135
- let(:unknown_count) { 1 }
136
-
137
- it "puts a message to stderr" do
138
- expect($stderr).to receive(:puts).with("Waiting for 1 verification result to be published (maximum of 5 seconds)")
139
- subject
140
- end
141
-
142
- it "retries the request" do
143
- expect(Retry).to receive(:until_truthy_or_max_times).with(hash_including(times: 1, sleep: 5, sleep_first: true))
144
- subject
145
- end
146
- end
147
-
148
- context "when the matrix does not support the unknown count" do
149
- let(:supports_unknown_count) { false }
150
-
151
- it "returns a failure response" do
152
- expect(subject.success).to be false
153
- end
154
-
155
- it "returns a failure message" do
156
- expect(subject.message).to match /does not provide a count/
157
- end
158
-
159
- context "when dry_run is enabled" do
160
- let(:dry_run) { true }
161
-
162
- it "returns a success response" do
163
- expect(subject.success).to be true
164
- end
165
-
166
- it "returns a failure message" do
167
- expect(subject.message).to include "[dry-run]"
168
- expect(subject.message).to match /does not provide a count/
169
- end
170
- end
171
- end
172
- end
173
-
174
- context "when there are ignore selectors but the matrix does not support ignoring" do
175
- let(:matrix_options) { { ignore_selectors: [{ pacticipant_name: "Foo" }]} }
176
- let(:supports_ignore) { false }
177
-
178
- context "when deployable" do
179
- it "returns a warning" do
180
- expect(subject.message).to include "does not support"
181
- end
182
- end
183
-
184
- context "when not deployable" do
185
- let(:deployable) { false }
186
-
187
- it "returns a warning" do
188
- expect(subject.message).to include "does not support"
189
- end
190
- end
191
- end
192
-
193
- context "when a PactBroker::Client::Error is raised" do
194
- before do
195
- allow(PactBroker::Client::Matrix::Query).to receive(:call).and_raise(PactBroker::Client::Error.new('error text'))
196
- end
197
-
198
- it "returns a failure response" do
199
- expect(subject.success).to be false
200
- end
201
-
202
- it "returns a failure message" do
203
- expect(subject.message).to include "error text"
204
- end
205
-
206
- context "when dry_run is enabled" do
207
- let(:dry_run) { true }
208
-
209
- it "returns a success response" do
210
- expect(subject.success).to be true
211
- end
212
-
213
- it "returns a failure message" do
214
- expect(subject.message).to include "[dry-run]"
215
- expect(subject.message).to match /error text/
216
- end
217
- end
218
- end
219
-
220
- context "when a StandardError is raised" do
221
- before do
222
- allow(Retry).to receive(:while_error) { |&block| block.call }
223
- allow($stderr).to receive(:puts)
224
- allow(PactBroker::Client::Matrix::Query).to receive(:call).and_raise(StandardError.new('error text'))
225
- end
226
-
227
- it "returns a failure response" do
228
- expect(subject.success).to be false
229
- end
230
-
231
- it "returns a failure message and backtrace" do
232
- expect(subject.message).to include "Error retrieving matrix. StandardError - error text"
233
- end
234
-
235
- context "when dry_run is enabled" do
236
- let(:dry_run) { true }
237
-
238
- it "returns a success response" do
239
- expect(subject.success).to be true
240
- end
241
-
242
- it "returns a failure message" do
243
- expect(subject.message).to include "[dry-run]"
244
- expect(subject.message).to match /error text/
245
- end
246
- end
247
- end
248
- end
249
- end
250
- end
@@ -1,196 +0,0 @@
1
- require 'pact_broker/client/cli/broker'
2
- require 'pact_broker/client/cli/version_selector_options_parser'
3
- require 'pact_broker/client/can_i_deploy'
4
- require 'ostruct'
5
-
6
- module PactBroker
7
- module Client
8
- module CLI
9
- describe Broker do
10
- before do
11
- subject.options = OpenStruct.new(minimum_valid_options)
12
- allow(VersionSelectorOptionsParser).to receive(:call).and_return(version_selectors)
13
- allow(CanIDeploy).to receive(:call).and_return(result)
14
- allow($stdout).to receive(:puts)
15
- allow($stderr).to receive(:puts)
16
- end
17
-
18
- let(:result) { instance_double('PactBroker::Client::CanIDeploy::Result', success: success, message: message) }
19
- let(:success) { true }
20
- let(:message) { 'message' }
21
- let(:version_selectors) { [{pacticipant: "Foo", version: "1"}] }
22
- let(:minimum_valid_options) do
23
- {
24
- broker_base_url: 'http://pact-broker',
25
- output: 'table',
26
- verbose: 'verbose',
27
- retry_while_unknown: 1,
28
- retry_interval: 2,
29
- limit: 1000,
30
- dry_run: false
31
- }
32
- end
33
-
34
- let(:invoke_can_i_deploy) { subject.can_i_deploy }
35
-
36
- it "parses the pacticipant names and versions" do
37
- expect(VersionSelectorOptionsParser).to receive(:call).with(ARGV)
38
- invoke_can_i_deploy
39
- end
40
-
41
- it "invokes the CanIDeploy service" do
42
- expect(CanIDeploy).to receive(:call).with(version_selectors, { to_tag: nil, to_environment: nil, limit: 1000, ignore_selectors: []}, {output: 'table', retry_while_unknown: 1, retry_interval: 2, dry_run: false, verbose: "verbose"}, { pact_broker_base_url: 'http://pact-broker', verbose: 'verbose' })
43
- invoke_can_i_deploy
44
- end
45
-
46
- context "with a missing --version and --latest" do
47
- let(:version_selectors) { [{pacticipant: "Foo", version: nil}] }
48
-
49
- it "raises an error" do
50
- expect { invoke_can_i_deploy }.to raise_error Thor::RequiredArgumentMissingError, /The version must be specified/
51
- end
52
- end
53
-
54
- context "with --to" do
55
- before do
56
- subject.options.to = 'prod'
57
- end
58
-
59
- it "passes the value as the matrix options" do
60
- expect(CanIDeploy).to receive(:call).with(anything, {to_tag: 'prod', to_environment: nil, limit: 1000, ignore_selectors: []}, anything, anything)
61
- invoke_can_i_deploy
62
- end
63
- end
64
-
65
- context "with --to-environment" do
66
- before do
67
- subject.options.to_environment = 'prod'
68
- end
69
-
70
- it "passes the value as the matrix options" do
71
- expect(CanIDeploy).to receive(:call).with(anything, {to_tag: nil, to_environment: 'prod', limit: 1000, ignore_selectors: []}, anything, anything)
72
- invoke_can_i_deploy
73
- end
74
-
75
- context "when the environment is an empty string" do
76
- before do
77
- subject.options.to_environment = ' '
78
- end
79
-
80
- it "raises an error" do
81
- expect { invoke_can_i_deploy }.to raise_error ::Thor::RequiredArgumentMissingError
82
- end
83
- end
84
- end
85
-
86
- context "with basic auth" do
87
- before do
88
- subject.options.broker_username = 'foo'
89
- subject.options.broker_password = 'bar'
90
- end
91
-
92
- it "invokes the CanIDeploy service with the basic auth credentials" do
93
- expect(CanIDeploy).to receive(:call).with(anything, anything, anything, { pact_broker_base_url: 'http://pact-broker', basic_auth: {username: "foo", password: "bar"}, verbose: 'verbose'})
94
- invoke_can_i_deploy
95
- end
96
- end
97
-
98
- context "with a bearer token" do
99
- before do
100
- subject.options.broker_token = "some token"
101
- end
102
-
103
- it "invokes the CanIDeploy service with the basic auth credentials" do
104
- expect(CanIDeploy).to receive(:call).with(anything, anything, anything, {pact_broker_base_url: 'http://pact-broker', token: "some token", verbose: 'verbose'})
105
- invoke_can_i_deploy
106
- end
107
- end
108
-
109
- context "when PACT_BROKER_CAN_I_DEPLOY_DRY_RUN=true" do
110
- before do
111
- allow(ENV).to receive(:[]).and_call_original
112
- allow(ENV).to receive(:[]).with("PACT_BROKER_CAN_I_DEPLOY_DRY_RUN").and_return("true")
113
- end
114
-
115
- it "invokes the CanIDeploy service with dry_run set to true" do
116
- expect(CanIDeploy).to receive(:call).with(anything, anything, hash_including(dry_run: true), anything)
117
- invoke_can_i_deploy
118
- end
119
- end
120
-
121
- context "when PACT_BROKER_CAN_I_DEPLOY_IGNORE=Some Service" do
122
- before do
123
- allow(ENV).to receive(:fetch).and_call_original
124
- allow(ENV).to receive(:fetch).with("PACT_BROKER_CAN_I_DEPLOY_IGNORE", "").and_return("Some Service, Some Other Service")
125
- end
126
-
127
- it "invokes the CanIDeploy service with ignore selectors" do
128
- expect(CanIDeploy).to receive(:call).with(anything, hash_including(ignore_selectors: [ { pacticipant: "Some Service" }, { pacticipant: "Some Other Service" } ]), anything, anything)
129
- invoke_can_i_deploy
130
- end
131
- end
132
-
133
- context "when successful" do
134
- it "prints the message to stdout" do
135
- expect($stdout).to receive(:puts).with(message)
136
- invoke_can_i_deploy
137
- end
138
- end
139
-
140
- context "when not successful" do
141
- let(:success) { false }
142
-
143
- it "prints the message to stderr" do
144
- expect($stdout).to receive(:puts).with(message)
145
- begin
146
- invoke_can_i_deploy
147
- rescue SystemExit
148
- end
149
- end
150
-
151
- it "exits with code 1" do
152
- exited_explicitly = false
153
- exited_explicitlyerror = nil
154
- begin
155
- invoke_can_i_deploy
156
- rescue SystemExit => e
157
- exited_explicitly = true
158
- error = e
159
- end
160
- expect(exited_explicitly).to be true
161
- expect(error.status).to be 1
162
- end
163
-
164
- context "when an exit status is specified" do
165
- before do
166
- allow(ENV).to receive(:fetch).and_call_original
167
- allow(ENV).to receive(:fetch).with('PACT_BROKER_CAN_I_DEPLOY_EXIT_CODE_BETA', '').and_return("0")
168
- end
169
-
170
- it "exits with the specified code" do
171
- exited_explicitly = false
172
- error = nil
173
- begin
174
- invoke_can_i_deploy
175
- rescue SystemExit => e
176
- exited_explicitly = true
177
- error = e
178
- end
179
- expect(exited_explicitly).to be true
180
- expect(error.status).to be 0
181
- end
182
-
183
- it "prints the configured exit code" do
184
- expect($stderr).to receive(:puts).with("Exiting can-i-deploy with configured exit code 0")
185
- expect($stdout).to receive(:puts).with(message)
186
- begin
187
- invoke_can_i_deploy
188
- rescue SystemExit
189
- end
190
- end
191
- end
192
- end
193
- end
194
- end
195
- end
196
- end
@@ -1,23 +0,0 @@
1
- require 'pact_broker/client/cli/broker'
2
- require 'pact_broker/client/webhooks/create'
3
-
4
- module PactBroker
5
- module Client
6
- module CLI
7
- describe Broker do
8
- describe "create_or_update_webhook" do
9
-
10
- let(:broker) { Broker.new }
11
-
12
- subject { broker.create_or_update_webhook "http://webhook" }
13
-
14
- it "calls PactBroker::Client::Webhooks::Create with the webhook params" do
15
- expect(broker).to receive(:run_webhook_commands).with("http://webhook")
16
-
17
- subject
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,23 +0,0 @@
1
- require 'pact_broker/client/cli/broker'
2
- require 'pact_broker/client/webhooks/create'
3
-
4
- module PactBroker
5
- module Client
6
- module CLI
7
- describe Broker do
8
- describe "create_webhook" do
9
-
10
- let(:broker) { Broker.new }
11
-
12
- subject { broker.create_webhook "http://webhook" }
13
-
14
- it "calls PactBroker::Client::Webhooks::Create with the webhook params" do
15
- expect(broker).to receive(:run_webhook_commands).with("http://webhook")
16
-
17
- subject
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end