pact_broker-client 1.51.2 → 1.52.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +43 -33
- data/doc/pacts/markdown/Pact Broker Client - Pact Broker.md +1 -0
- data/lib/pact_broker/client/cli/deployment_commands.rb +7 -3
- data/lib/pact_broker/client/deployments/record_deployment.rb +6 -5
- data/lib/pact_broker/client/deployments/record_undeployment.rb +20 -12
- data/lib/pact_broker/client/version.rb +1 -1
- data/script/record-deployments-and-releases.sh +12 -1
- data/spec/lib/pact_broker/client/deployments/record_deployment_spec.rb +6 -6
- data/spec/lib/pact_broker/client/deployments/record_undeployment_spec.rb +15 -7
- data/spec/pacts/pact_broker_client-pact_broker.json +1 -0
- data/spec/service_providers/record_deployment_spec.rb +7 -6
- data/spec/service_providers/record_undeployment_spec.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c645adf22b85e738f227eec38baf09fe06241aeaeb4c75abc4c4558c66c2716f
|
4
|
+
data.tar.gz: e32efad31615c7335df1c36dea365fcc5e001574143a3df3d98e23c1c5c84c71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02c18bab0a1d08d568524ccd0a48d526e2aebf3d17db29dc83884f82db4c4ebf9864fd2e6d3de01ab6b11febc658d94efe28a817f351266059771fff8a95a446
|
7
|
+
data.tar.gz: d647f077b021640b520babbc4e7ba5ed8bd4d460ebe826e98900f356bbd79dda96ee7c425d0ee6eeff7aa2648f996ded578f22a24708b8efdf5725cfd8fd97b9
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
<a name="v1.52.0"></a>
|
2
|
+
### v1.52.0 (2021-09-29)
|
3
|
+
|
4
|
+
#### Features
|
5
|
+
|
6
|
+
* rename target to application-instance for record-deployment and record-undeployment (backwards compatible) ([53d23eb](/../../commit/53d23eb))
|
7
|
+
|
1
8
|
<a name="v1.51.2"></a>
|
2
9
|
### v1.51.2 (2021-09-27)
|
3
10
|
|
data/README.md
CHANGED
@@ -275,29 +275,33 @@ Usage:
|
|
275
275
|
pact-broker record-deployment --environment=ENVIRONMENT -a, --pacticipant=PACTICIPANT -b, --broker-base-url=BROKER_BASE_URL -e, --version=VERSION
|
276
276
|
|
277
277
|
Options:
|
278
|
-
-a, --pacticipant=PACTICIPANT
|
278
|
+
-a, --pacticipant=PACTICIPANT
|
279
279
|
# The name of the pacticipant that was deployed.
|
280
|
-
-e, --version=VERSION
|
280
|
+
-e, --version=VERSION
|
281
281
|
# The pacticipant version number that was deployed.
|
282
|
-
--environment=ENVIRONMENT
|
282
|
+
--environment=ENVIRONMENT
|
283
283
|
# The name of the environment that the pacticipant version was
|
284
284
|
deployed to.
|
285
|
-
[--
|
286
|
-
# Optional. The
|
287
|
-
|
288
|
-
instances of the same
|
289
|
-
|
285
|
+
[--application-instance=APPLICATION_INSTANCE]
|
286
|
+
# Optional. The application instance to which the deployment has
|
287
|
+
occurred - a logical identifer required to differentiate
|
288
|
+
deployments when there are multiple instances of the same
|
289
|
+
application in an environment. This field was called 'target'
|
290
|
+
in a beta release.
|
291
|
+
[--target=TARGET]
|
292
|
+
# Renamed to application_instance
|
293
|
+
-o, [--output=OUTPUT]
|
290
294
|
# json or text
|
291
295
|
# Default: text
|
292
|
-
-b, --broker-base-url=BROKER_BASE_URL
|
296
|
+
-b, --broker-base-url=BROKER_BASE_URL
|
293
297
|
# The base URL of the Pact Broker
|
294
|
-
-u, [--broker-username=BROKER_USERNAME]
|
298
|
+
-u, [--broker-username=BROKER_USERNAME]
|
295
299
|
# Pact Broker basic auth username
|
296
|
-
-p, [--broker-password=BROKER_PASSWORD]
|
300
|
+
-p, [--broker-password=BROKER_PASSWORD]
|
297
301
|
# Pact Broker basic auth password
|
298
|
-
-k, [--broker-token=BROKER_TOKEN]
|
302
|
+
-k, [--broker-token=BROKER_TOKEN]
|
299
303
|
# Pact Broker bearer token
|
300
|
-
-v, [--verbose], [--no-verbose]
|
304
|
+
-v, [--verbose], [--no-verbose]
|
301
305
|
# Verbose output. Default: false
|
302
306
|
```
|
303
307
|
|
@@ -310,28 +314,34 @@ Usage:
|
|
310
314
|
pact-broker record-undeployment --environment=ENVIRONMENT -a, --pacticipant=PACTICIPANT -b, --broker-base-url=BROKER_BASE_URL
|
311
315
|
|
312
316
|
Options:
|
313
|
-
-a, --pacticipant=PACTICIPANT
|
317
|
+
-a, --pacticipant=PACTICIPANT
|
314
318
|
# The name of the pacticipant that was undeployed.
|
315
|
-
--environment=ENVIRONMENT
|
319
|
+
--environment=ENVIRONMENT
|
316
320
|
# The name of the environment that the pacticipant version was
|
317
321
|
undeployed from.
|
318
|
-
[--
|
322
|
+
[--application-instance=APPLICATION_INSTANCE]
|
323
|
+
# Optional. The application instance from which the application
|
324
|
+
is being undeployed - a logical identifer required to
|
325
|
+
differentiate deployments when there are multiple instances of
|
326
|
+
the same application in an environment. This field was called
|
327
|
+
'target' in a beta release.
|
328
|
+
[--target=TARGET]
|
319
329
|
# Optional. The target that the application is being undeployed
|
320
330
|
from - a logical identifer required to differentiate
|
321
331
|
deployments when there are multiple instances of the same
|
322
332
|
application in an environment.
|
323
|
-
-o, [--output=OUTPUT]
|
333
|
+
-o, [--output=OUTPUT]
|
324
334
|
# json or text
|
325
335
|
# Default: text
|
326
|
-
-b, --broker-base-url=BROKER_BASE_URL
|
336
|
+
-b, --broker-base-url=BROKER_BASE_URL
|
327
337
|
# The base URL of the Pact Broker
|
328
|
-
-u, [--broker-username=BROKER_USERNAME]
|
338
|
+
-u, [--broker-username=BROKER_USERNAME]
|
329
339
|
# Pact Broker basic auth username
|
330
|
-
-p, [--broker-password=BROKER_PASSWORD]
|
340
|
+
-p, [--broker-password=BROKER_PASSWORD]
|
331
341
|
# Pact Broker basic auth password
|
332
|
-
-k, [--broker-token=BROKER_TOKEN]
|
342
|
+
-k, [--broker-token=BROKER_TOKEN]
|
333
343
|
# Pact Broker bearer token
|
334
|
-
-v, [--verbose], [--no-verbose]
|
344
|
+
-v, [--verbose], [--no-verbose]
|
335
345
|
# Verbose output. Default: false
|
336
346
|
```
|
337
347
|
|
@@ -469,8 +479,8 @@ Description:
|
|
469
479
|
support for environments, deployments and releases. For documentation on how to use can-i-deploy with tags, please see
|
470
480
|
https://docs.pact.io/pact_broker/client_cli/can_i_deploy_usage_with_tags/
|
471
481
|
|
472
|
-
Before `can-i-deploy` can be used, the relevant environment resources must first be created in the Pact Broker using the `create-environment` command. The
|
473
|
-
and "production" environments will have been seeded for you. You can check the existing environments by running `pact-broker list-environments`. See
|
482
|
+
Before `can-i-deploy` can be used, the relevant environment resources must first be created in the Pact Broker using the `create-environment` command. The
|
483
|
+
"test" and "production" environments will have been seeded for you. You can check the existing environments by running `pact-broker list-environments`. See
|
474
484
|
https://docs.pact.io/pact_broker/client_cli/readme#environments for more information.
|
475
485
|
|
476
486
|
$ pact-broker create-environment --name "uat" --display-name "UAT" --no-production
|
@@ -480,8 +490,8 @@ Description:
|
|
480
490
|
|
481
491
|
$ pact-broker record-deployment --pacticipant Foo --version 173153ae0 --environment uat
|
482
492
|
|
483
|
-
Before an application is deployed or released to an environment, the can-i-deploy command must be run to check that the application version is safe to deploy
|
484
|
-
the versions of each integrated application that are already in that environment.
|
493
|
+
Before an application is deployed or released to an environment, the can-i-deploy command must be run to check that the application version is safe to deploy
|
494
|
+
with the versions of each integrated application that are already in that environment.
|
485
495
|
|
486
496
|
$ pact-broker can-i-deploy --pacticipant PACTICIPANT --version VERSION --to-environment ENVIRONMENT
|
487
497
|
|
@@ -489,8 +499,8 @@ Description:
|
|
489
499
|
|
490
500
|
$ pact-broker can-i-deploy --pacticipant Foo --version 173153ae0 --to-environment test
|
491
501
|
|
492
|
-
Can-i-deploy can also be used to check if arbitrary versions have a successful verification. When asking "Can I deploy this application version with the
|
493
|
-
from the main branch of another application" it functions as a "can I merge" check.
|
502
|
+
Can-i-deploy can also be used to check if arbitrary versions have a successful verification. When asking "Can I deploy this application version with the
|
503
|
+
latest version from the main branch of another application" it functions as a "can I merge" check.
|
494
504
|
|
495
505
|
$ pact-broker can-i-deploy --pacticipant Foo 173153ae0 \ --pacticipant Bar --latest main
|
496
506
|
|
@@ -628,8 +638,8 @@ Options:
|
|
628
638
|
```
|
629
639
|
|
630
640
|
Description:
|
631
|
-
Create a curl command that executes the request that you want your webhook to execute, then replace "curl" with "pact-broker create-webhook" and add the
|
632
|
-
provider, event types and broker details. Note that the URL must be the first parameter when executing create-webhook.
|
641
|
+
Create a curl command that executes the request that you want your webhook to execute, then replace "curl" with "pact-broker create-webhook" and add the
|
642
|
+
consumer, provider, event types and broker details. Note that the URL must be the first parameter when executing create-webhook.
|
633
643
|
|
634
644
|
Note that the -u option from the curl command clashes with the -u option from the pact-broker CLI. When used in this command, the -u will be used as a curl
|
635
645
|
option. Please use the --broker-username or environment variable for the Pact Broker username.
|
@@ -686,9 +696,9 @@ Options:
|
|
686
696
|
```
|
687
697
|
|
688
698
|
Description:
|
689
|
-
Create a curl command that executes the request that you want your webhook to execute, then replace "curl" with "pact-broker create-or-update-webhook" and
|
690
|
-
consumer, provider, event types and broker details. Note that the URL must be the first parameter when executing create-or-update-webhook and a uuid
|
691
|
-
also be provided. You can generate a valid UUID by using the `generate-uuid` command.
|
699
|
+
Create a curl command that executes the request that you want your webhook to execute, then replace "curl" with "pact-broker create-or-update-webhook" and
|
700
|
+
add the consumer, provider, event types and broker details. Note that the URL must be the first parameter when executing create-or-update-webhook and a uuid
|
701
|
+
must also be provided. You can generate a valid UUID by using the `generate-uuid` command.
|
692
702
|
|
693
703
|
Note that the -u option from the curl command clashes with the -u option from the pact-broker CLI. When used in this command, the -u will be used as a curl
|
694
704
|
option. Please use the --broker-username or environment variable for the Pact Broker username.
|
@@ -14,16 +14,18 @@ module PactBroker
|
|
14
14
|
method_option :pacticipant, required: true, aliases: "-a", desc: "The name of the pacticipant that was deployed."
|
15
15
|
method_option :version, required: true, aliases: "-e", desc: "The pacticipant version number that was deployed."
|
16
16
|
method_option :environment, required: true, desc: "The name of the environment that the pacticipant version was deployed to."
|
17
|
-
method_option :
|
17
|
+
method_option :application_instance, default: nil, required: false, desc: "Optional. The application instance to which the deployment has occurred - a logical identifer required to differentiate deployments when there are multiple instances of the same application in an environment. This field was called 'target' in a beta release."
|
18
|
+
method_option :target, hidden: true, default: nil, required: false, desc: "Renamed to application_instance"
|
18
19
|
output_option_json_or_text
|
19
20
|
shared_authentication_options
|
20
21
|
|
21
22
|
def record_deployment
|
23
|
+
$stderr.puts("WARN: target has been renamed to application-instance") if options.target
|
22
24
|
params = {
|
23
25
|
pacticipant_name: options.pacticipant,
|
24
26
|
version_number: options.version,
|
25
27
|
environment_name: options.environment,
|
26
|
-
|
28
|
+
application_instance: options.application_instance || options.target
|
27
29
|
}
|
28
30
|
execute_deployment_command(params, "RecordDeployment")
|
29
31
|
end
|
@@ -32,15 +34,17 @@ module PactBroker
|
|
32
34
|
long_desc "Note that use of this command is only required if you are permanently removing an application instance from an environment. It is not required if you are deploying over a previous version, as record-deployment will automatically mark the previously deployed version as undeployed for you. See #{RECORD_UNDEPLOYMENT_HELP_URL} for more information."
|
33
35
|
method_option :pacticipant, required: true, aliases: "-a", desc: "The name of the pacticipant that was undeployed."
|
34
36
|
method_option :environment, required: true, desc: "The name of the environment that the pacticipant version was undeployed from."
|
37
|
+
method_option :application_instance, default: nil, required: false, desc: "Optional. The application instance from which the application is being undeployed - a logical identifer required to differentiate deployments when there are multiple instances of the same application in an environment. This field was called 'target' in a beta release."
|
35
38
|
method_option :target, default: nil, required: false, desc: "Optional. The target that the application is being undeployed from - a logical identifer required to differentiate deployments when there are multiple instances of the same application in an environment."
|
36
39
|
output_option_json_or_text
|
37
40
|
shared_authentication_options
|
38
41
|
|
39
42
|
def record_undeployment
|
43
|
+
$stderr.puts("WARN: target has been renamed to application-instance") if options.target
|
40
44
|
params = {
|
41
45
|
pacticipant_name: options.pacticipant,
|
42
46
|
environment_name: options.environment,
|
43
|
-
|
47
|
+
application_instance: options.application_instance || options.target
|
44
48
|
}
|
45
49
|
execute_deployment_command(params, "RecordUndeployment")
|
46
50
|
end
|
@@ -6,12 +6,12 @@ module PactBroker
|
|
6
6
|
class RecordDeployment < PactBroker::Client::Deployments::RecordRelease
|
7
7
|
def initialize(params, options, pact_broker_client_options)
|
8
8
|
super
|
9
|
-
@
|
9
|
+
@application_instance = params.fetch(:application_instance)
|
10
10
|
end
|
11
11
|
|
12
12
|
private
|
13
13
|
|
14
|
-
attr_reader :
|
14
|
+
attr_reader :application_instance
|
15
15
|
|
16
16
|
def action
|
17
17
|
"deployment"
|
@@ -22,12 +22,13 @@ module PactBroker
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def record_action_request_body
|
25
|
-
|
25
|
+
# for backwards compatibility with old broker
|
26
|
+
{ applicationInstance: application_instance, target: application_instance }.compact
|
26
27
|
end
|
27
28
|
|
28
29
|
def result_text_message
|
29
|
-
if
|
30
|
-
"#{super} (
|
30
|
+
if application_instance
|
31
|
+
"#{super} (application instance #{application_instance})"
|
31
32
|
else
|
32
33
|
super
|
33
34
|
end
|
@@ -8,7 +8,7 @@ module PactBroker
|
|
8
8
|
super
|
9
9
|
@pacticipant_name = params.fetch(:pacticipant_name)
|
10
10
|
@environment_name = params.fetch(:environment_name)
|
11
|
-
@
|
11
|
+
@application_instance = params.fetch(:application_instance)
|
12
12
|
end
|
13
13
|
|
14
14
|
private
|
@@ -21,7 +21,7 @@ module PactBroker
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
attr_reader :pacticipant_name, :environment_name, :
|
24
|
+
attr_reader :pacticipant_name, :environment_name, :application_instance
|
25
25
|
|
26
26
|
def currently_deployed_versions_link
|
27
27
|
environment_resource._link("pb:currently-deployed-deployed-versions", "pb:currently-deployed-versions") or raise PactBroker::Client::Error.new(not_supported_message)
|
@@ -31,14 +31,19 @@ module PactBroker
|
|
31
31
|
@deployed_version_links ||= currently_deployed_versions_link.get!(pacticipant: pacticipant_name).embedded_entities!("deployedVersions")
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
34
|
+
def currently_deployed_version_entities_for_pacticipant_and_instance
|
35
35
|
currently_deployed_version_entities_for_pacticipant.select do | entity |
|
36
|
-
|
36
|
+
if application_instance
|
37
|
+
entity.applicationInstance == application_instance || entity.target == application_instance
|
38
|
+
else
|
39
|
+
entity.applicationInstance == nil && entity.target == nil
|
40
|
+
end
|
41
|
+
|
37
42
|
end
|
38
43
|
end
|
39
44
|
|
40
45
|
def undeployed_versions_resources
|
41
|
-
@undeployed_versions_resources ||=
|
46
|
+
@undeployed_versions_resources ||= currently_deployed_version_entities_for_pacticipant_and_instance.collect do | entity |
|
42
47
|
entity._link!("self").patch(currentlyDeployed: false)
|
43
48
|
end
|
44
49
|
end
|
@@ -75,7 +80,7 @@ module PactBroker
|
|
75
80
|
message = "Recorded #{action} of #{pacticipant_name}"
|
76
81
|
message = "#{message} version #{version.number}" if (version && version.number)
|
77
82
|
message = "#{message} from #{environment_name} environment"
|
78
|
-
message = "#{message} (
|
83
|
+
message = "#{message} (application instance #{application_instance})" if application_instance
|
79
84
|
message
|
80
85
|
end
|
81
86
|
|
@@ -92,19 +97,22 @@ module PactBroker
|
|
92
97
|
"No pacticipant with name '#{pacticipant_name}' found."
|
93
98
|
else
|
94
99
|
if currently_deployed_version_entities_for_pacticipant.any?
|
95
|
-
|
100
|
+
application_instance_does_not_match_message
|
96
101
|
else
|
97
102
|
"#{pacticipant_name} is not currently deployed to #{environment_name} environment. Cannot record undeployment."
|
98
103
|
end
|
99
104
|
end
|
100
105
|
end
|
101
106
|
|
102
|
-
def
|
103
|
-
|
104
|
-
|
105
|
-
|
107
|
+
def application_instance_does_not_match_message
|
108
|
+
potential_application_instances = currently_deployed_version_entities_for_pacticipant.collect{|e| e.applicationInstance || e.target }
|
109
|
+
|
110
|
+
if application_instance
|
111
|
+
omit_text = potential_application_instances.include?(nil) ? "omit the application instance to undeploy from the anonymous instance" : nil
|
112
|
+
specify_text = potential_application_instances.compact.any? ? "specify one of the following application instances to record the undeployment from: #{potential_application_instances.compact.join(", ")}" : nil
|
113
|
+
"#{pacticipant_name} is not currently deployed to application instance '#{application_instance}' in #{environment_name} environment. Please #{[omit_text, specify_text].compact.join(" or ")}."
|
106
114
|
else
|
107
|
-
"Please specify one of the following
|
115
|
+
"Please specify one of the following application instances to record the undeployment from: #{potential_application_instances.compact.join(", ")}"
|
108
116
|
end
|
109
117
|
end
|
110
118
|
|
@@ -8,9 +8,20 @@ bundle exec bin/pact-broker record-deployment --pacticipant Foo --version 2 --en
|
|
8
8
|
bundle exec bin/pact-broker record-deployment --pacticipant Foo --version 2 --environment test --target customer-1
|
9
9
|
bundle exec bin/pact-broker record-deployment --pacticipant Foo --version 2 --environment test --target customer-1
|
10
10
|
|
11
|
+
bundle exec bin/pact-broker record-undeployment --pacticipant Foo --environment test --target customer-2
|
11
12
|
bundle exec bin/pact-broker record-undeployment --pacticipant Foo --environment test
|
12
13
|
bundle exec bin/pact-broker record-undeployment --pacticipant Foo --environment test
|
13
14
|
bundle exec bin/pact-broker record-undeployment --pacticipant Foo --environment test --target customer-1
|
14
15
|
|
15
16
|
bundle exec bin/pact-broker record-release --pacticipant Foo --version 2 --environment test
|
16
|
-
bundle exec bin/pact-broker record-support-ended --pacticipant Foo --version 2 --environment test
|
17
|
+
bundle exec bin/pact-broker record-support-ended --pacticipant Foo --version 2 --environment test
|
18
|
+
|
19
|
+
|
20
|
+
bundle exec bin/pact-broker record-deployment --pacticipant Foo --version 2 --environment test
|
21
|
+
bundle exec bin/pact-broker record-deployment --pacticipant Foo --version 2 --environment test --application-instance customer-1
|
22
|
+
bundle exec bin/pact-broker record-deployment --pacticipant Foo --version 2 --environment test --application-instance customer-1
|
23
|
+
|
24
|
+
bundle exec bin/pact-broker record-undeployment --pacticipant Foo --environment test --application-instance customer-2
|
25
|
+
bundle exec bin/pact-broker record-undeployment --pacticipant Foo --environment test
|
26
|
+
bundle exec bin/pact-broker record-undeployment --pacticipant Foo --environment test
|
27
|
+
bundle exec bin/pact-broker record-undeployment --pacticipant Foo --environment test --application-instance customer-1
|
@@ -61,14 +61,14 @@ module PactBroker
|
|
61
61
|
to_return(status: 200, body: record_deployment_body_hash.to_json , headers: {})
|
62
62
|
end
|
63
63
|
|
64
|
-
let(:
|
64
|
+
let(:application_instance) { "blue" }
|
65
65
|
|
66
66
|
let(:params) do
|
67
67
|
{
|
68
68
|
pacticipant_name: "Foo",
|
69
69
|
version_number: "1",
|
70
70
|
environment_name: "test",
|
71
|
-
|
71
|
+
application_instance: application_instance
|
72
72
|
}
|
73
73
|
end
|
74
74
|
|
@@ -186,13 +186,13 @@ module PactBroker
|
|
186
186
|
end
|
187
187
|
|
188
188
|
it "indicates the API was Pactflow" do
|
189
|
-
expect(subject.message).to include "Recorded deployment of Foo version 1 to test environment (
|
189
|
+
expect(subject.message).to include "Recorded deployment of Foo version 1 to test environment (application instance blue) in Pactflow"
|
190
190
|
end
|
191
191
|
|
192
|
-
context "when
|
193
|
-
let(:
|
192
|
+
context "when application_instance is nil" do
|
193
|
+
let(:application_instance) { nil }
|
194
194
|
|
195
|
-
it "does not include the
|
195
|
+
it "does not include the application_instance in the result message" do
|
196
196
|
expect(subject.message).to include "Recorded deployment of Foo version 1 to test environment in"
|
197
197
|
end
|
198
198
|
end
|
@@ -7,11 +7,11 @@ module PactBroker
|
|
7
7
|
let(:params) do
|
8
8
|
{
|
9
9
|
pacticipant_name: "Foo",
|
10
|
-
|
10
|
+
application_instance: application_instance,
|
11
11
|
environment_name: "test"
|
12
12
|
}
|
13
13
|
end
|
14
|
-
let(:
|
14
|
+
let(:application_instance) { "customer-1" }
|
15
15
|
let(:output) { "text" }
|
16
16
|
let(:options) { { output: output, verbose: true } }
|
17
17
|
let(:pact_broker_base_url) { "http://broker" }
|
@@ -131,7 +131,7 @@ module PactBroker
|
|
131
131
|
subject { RecordUndeployment.call(params, options, pact_broker_client_options) }
|
132
132
|
|
133
133
|
its(:success) { is_expected.to eq true }
|
134
|
-
its(:message) { is_expected.to include "Recorded undeployment of Foo version 2 from test environment (
|
134
|
+
its(:message) { is_expected.to include "Recorded undeployment of Foo version 2 from test environment (application instance customer-1) in the Pact Broker" }
|
135
135
|
|
136
136
|
context "when there is no pb:environments relation in the index" do
|
137
137
|
let(:index_body_hash) do
|
@@ -173,8 +173,8 @@ module PactBroker
|
|
173
173
|
end
|
174
174
|
|
175
175
|
context "when a target is provided and there is no deployed version with a matching target" do
|
176
|
-
let(:
|
177
|
-
let(:expected_message) { "Foo is not currently deployed to
|
176
|
+
let(:application_instance) { "wrong" }
|
177
|
+
let(:expected_message) { "Foo is not currently deployed to application instance 'wrong' in test environment. Please omit the application instance to undeploy from the anonymous instance or specify one of the following application instances to record the undeployment from: customer-1." }
|
178
178
|
|
179
179
|
its(:success) { is_expected.to be false }
|
180
180
|
its(:message) { is_expected.to include expected_message }
|
@@ -186,12 +186,20 @@ module PactBroker
|
|
186
186
|
end
|
187
187
|
end
|
188
188
|
|
189
|
+
context "when a target is provided and there is no deployed version with a matching target and all the application instances are set" do
|
190
|
+
let(:application_instance) { "wrong" }
|
191
|
+
let(:returned_target_2) { "customer-2" }
|
192
|
+
let(:expected_message) { "Foo is not currently deployed to application instance 'wrong' in test environment. Please specify one of the following application instances to record the undeployment from: customer-1, customer-2." }
|
193
|
+
|
194
|
+
its(:message) { is_expected.to include expected_message }
|
195
|
+
end
|
196
|
+
|
189
197
|
context "when a target is not provided and there is no deployed verison without a target" do
|
190
|
-
let(:
|
198
|
+
let(:application_instance) { nil }
|
191
199
|
let(:returned_target_2) { "customer-2" }
|
192
200
|
|
193
201
|
its(:success) { is_expected.to be false }
|
194
|
-
its(:message) { is_expected.to include "Please specify one of the following
|
202
|
+
its(:message) { is_expected.to include "Please specify one of the following application instances to record the undeployment from: customer-1, customer-2" }
|
195
203
|
end
|
196
204
|
|
197
205
|
context "when there are no deployed versions for the pacticipant" do
|
@@ -9,13 +9,13 @@ RSpec.describe "recording a deployment", pact: true do
|
|
9
9
|
let(:version_number) { "5556b8149bf8bac76bc30f50a8a2dd4c22c85f30" }
|
10
10
|
let(:environment_name) { "test" }
|
11
11
|
let(:output) { "text" }
|
12
|
-
let(:
|
12
|
+
let(:application_instance) { "blue" }
|
13
13
|
let(:params) do
|
14
14
|
{
|
15
15
|
pacticipant_name: pacticipant_name,
|
16
16
|
version_number: version_number,
|
17
17
|
environment_name: environment_name,
|
18
|
-
|
18
|
+
application_instance: application_instance
|
19
19
|
}
|
20
20
|
end
|
21
21
|
let(:options) do
|
@@ -139,14 +139,15 @@ RSpec.describe "recording a deployment", pact: true do
|
|
139
139
|
path: "/HAL-REL-PLACEHOLDER-PB-RECORD-DEPLOYMENT-FOO-5556B8149BF8BAC76BC30F50A8A2DD4C22C85F30-TEST",
|
140
140
|
headers: post_request_headers,
|
141
141
|
body: {
|
142
|
-
|
142
|
+
applicationInstance: application_instance,
|
143
|
+
target: application_instance
|
143
144
|
}
|
144
145
|
)
|
145
146
|
.will_respond_with(
|
146
147
|
status: 201,
|
147
148
|
headers: pact_broker_response_headers,
|
148
149
|
body: {
|
149
|
-
target:
|
150
|
+
target: application_instance
|
150
151
|
}
|
151
152
|
)
|
152
153
|
end
|
@@ -160,14 +161,14 @@ RSpec.describe "recording a deployment", pact: true do
|
|
160
161
|
|
161
162
|
it "returns a success message" do
|
162
163
|
expect(subject.success).to be true
|
163
|
-
expect(subject.message).to include "Recorded deployment of Foo version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 to test environment (
|
164
|
+
expect(subject.message).to include "Recorded deployment of Foo version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 to test environment (application instance blue) in the Pact Broker."
|
164
165
|
end
|
165
166
|
|
166
167
|
context "when the output is json" do
|
167
168
|
let(:output) { "json" }
|
168
169
|
|
169
170
|
it "returns the JSON payload" do
|
170
|
-
expect(JSON.parse(subject.message)).to eq "target" =>
|
171
|
+
expect(JSON.parse(subject.message)).to eq "target" => application_instance
|
171
172
|
end
|
172
173
|
end
|
173
174
|
end
|
@@ -8,12 +8,12 @@ RSpec.describe "recording an undeployment", pact: true do
|
|
8
8
|
let(:pacticipant_name) { "Foo" }
|
9
9
|
let(:environment_name) { "test" }
|
10
10
|
let(:output) { "text" }
|
11
|
-
let(:
|
11
|
+
let(:application_instance) { "customer-1" }
|
12
12
|
let(:params) do
|
13
13
|
{
|
14
14
|
pacticipant_name: pacticipant_name,
|
15
15
|
environment_name: environment_name,
|
16
|
-
|
16
|
+
application_instance: application_instance
|
17
17
|
}
|
18
18
|
end
|
19
19
|
let(:options) do
|
@@ -100,7 +100,7 @@ RSpec.describe "recording an undeployment", pact: true do
|
|
100
100
|
_embedded: {
|
101
101
|
deployedVersions: [
|
102
102
|
{
|
103
|
-
target:
|
103
|
+
target: application_instance,
|
104
104
|
_links: {
|
105
105
|
self: {
|
106
106
|
href: Pact.term(pact_broker.mock_service_base_url + deployed_version_placeholder_path, /^http/)
|
@@ -150,7 +150,7 @@ RSpec.describe "recording an undeployment", pact: true do
|
|
150
150
|
|
151
151
|
it "returns a success message" do
|
152
152
|
expect(subject.success).to be true
|
153
|
-
expect(subject.message).to include "Recorded undeployment of Foo version 2 from test environment (
|
153
|
+
expect(subject.message).to include "Recorded undeployment of Foo version 2 from test environment (application instance customer-1) in the Pact Broker"
|
154
154
|
end
|
155
155
|
|
156
156
|
context "when the output is json" do
|
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.52.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: 2021-09-
|
11
|
+
date: 2021-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|