pact_broker-client 1.10.0 → 1.11.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 +18 -0
- data/lib/pact_broker/client/cli/broker.rb +24 -3
- data/lib/pact_broker/client/cli/custom_thor.rb +18 -1
- data/lib/pact_broker/client/cli/version_selector_options_parser.rb +6 -0
- data/lib/pact_broker/client/create_tag.rb +49 -0
- data/lib/pact_broker/client/matrix.rb +10 -1
- data/lib/pact_broker/client/retry.rb +1 -1
- data/lib/pact_broker/client/version.rb +1 -1
- data/spec/integration/create_version_tag_spec.rb +20 -0
- data/spec/lib/pact_broker/client/cli/broker_can_i_deploy_spec.rb +2 -2
- data/spec/lib/pact_broker/client/cli/custom_thor_spec.rb +34 -0
- data/spec/lib/pact_broker/client/cli/version_selector_options_parser_spec.rb +6 -0
- data/spec/pacts/pact_broker_client-pact_broker.json +96 -0
- data/spec/service_providers/pact_broker_client_matrix_spec.rb +52 -0
- data/spec/spec_helper.rb +8 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e145049914705be5d6fbf40b0c558fa03b1f721
|
4
|
+
data.tar.gz: 1af03d94ccc879a70f04297a8d2e3fe41878c446
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf7f69734f2cc5195ab2b9ad04647ef10a8d841488132fc327db0bc363076dee6ed6b2e97a7a78930e59f72fc270c62a4588387692a5b84ab6625f54b9871db4
|
7
|
+
data.tar.gz: 96760c522ae3663b570d53537bb0af321bd9d24cf74c945cb7a7cc96118b076e44434e09ff175b5fffef45c1f9a58896ea69a468ac5330778c6c7b98d0310015
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
<a name="v1.11.0"></a>
|
2
|
+
### v1.11.0 (2017-11-01)
|
3
|
+
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* **can-i-deploy**
|
8
|
+
* add --latest option to command line ([c7f012d](/../../commit/c7f012d))
|
9
|
+
|
10
|
+
* allow broker base url, username and password to be set by environment variables ([3516103](/../../commit/3516103))
|
11
|
+
|
12
|
+
* **cli**
|
13
|
+
* add one line of backtrace to error output ([c2ede03](/../../commit/c2ede03))
|
14
|
+
|
15
|
+
* **create-version-tag**
|
16
|
+
* add CLI to tag a pacticipant version ([c62d9b8](/../../commit/c62d9b8))
|
17
|
+
|
18
|
+
|
1
19
|
<a name="v1.10.0"></a>
|
2
20
|
### v1.10.0 (2017-10-31)
|
3
21
|
|
@@ -6,6 +6,7 @@ require 'pact_broker/client/cli/custom_thor'
|
|
6
6
|
require 'pact_broker/client/publish_pacts'
|
7
7
|
require 'rake/file_list'
|
8
8
|
require 'thor/error'
|
9
|
+
require 'pact_broker/client/create_tag'
|
9
10
|
|
10
11
|
module PactBroker
|
11
12
|
module Client
|
@@ -17,7 +18,8 @@ module PactBroker
|
|
17
18
|
desc 'can-i-deploy', "Returns exit code 0 or 1, indicating whether or not the specified application versions are compatible."
|
18
19
|
|
19
20
|
method_option :pacticipant, required: true, aliases: "-a", desc: "The pacticipant name. Use once for each pacticipant being checked."
|
20
|
-
method_option :version, required:
|
21
|
+
method_option :version, required: false, aliases: "-e", desc: "The pacticipant version. Must be entered after the --pacticipant that it relates to."
|
22
|
+
method_option :latest, required: false, aliases: "-l", banner: '[TAG]', desc: "Use the latest pacticipant version. Optionally specify a TAG to use the latest version with the specified tag."
|
21
23
|
method_option :broker_base_url, required: true, aliases: "-b", desc: "The base URL of the Pact Broker"
|
22
24
|
method_option :broker_username, aliases: "-u", desc: "Pact Broker basic auth username"
|
23
25
|
method_option :broker_password, aliases: "-p", desc: "Pact Broker basic auth password"
|
@@ -49,6 +51,25 @@ module PactBroker
|
|
49
51
|
raise PactPublicationError, "#{e.class} - #{e.message}"
|
50
52
|
end
|
51
53
|
|
54
|
+
desc 'create-version-tag', 'Add a tag to a pacticipant version'
|
55
|
+
method_option :pacticipant, required: true, aliases: "-a", desc: "The pacticipant name"
|
56
|
+
method_option :version, required: true, aliases: "-e", desc: "The pacticipant version"
|
57
|
+
method_option :tag, aliases: "-t", type: :array, banner: "TAG", desc: "Tag name for pacticipant version. Can be specified multiple times."
|
58
|
+
method_option :tag_with_git_branch, aliases: "-g", type: :boolean, default: false, required: false, desc: "Tag pacticipant version with the name of the current git branch. Default: false"
|
59
|
+
method_option :broker_base_url, required: true, aliases: "-b", desc: "The base URL of the Pact Broker"
|
60
|
+
method_option :broker_username, aliases: "-u", desc: "Pact Broker basic auth username"
|
61
|
+
method_option :broker_password, aliases: "-p", desc: "Pact Broker basic auth password"
|
62
|
+
method_option :verbose, aliases: "-v", type: :boolean, default: false, required: false, desc: "Verbose output. Default: false"
|
63
|
+
|
64
|
+
def create_version_tag
|
65
|
+
PactBroker::Client::CreateTag.call(
|
66
|
+
options.broker_base_url,
|
67
|
+
options.pacticipant,
|
68
|
+
options.version,
|
69
|
+
tags,
|
70
|
+
pact_broker_client_options)
|
71
|
+
end
|
72
|
+
|
52
73
|
desc 'version', "Show the pact_broker-client gem version"
|
53
74
|
def version
|
54
75
|
$stdout.puts PactBroker::Client::VERSION
|
@@ -67,8 +88,8 @@ module PactBroker
|
|
67
88
|
end
|
68
89
|
|
69
90
|
def validate_can_i_deploy_selectors selectors
|
70
|
-
pacticipants_without_versions = selectors.select{ |s| s[:version].nil? }.collect{ |s| s[:pacticipant] }
|
71
|
-
raise ::Thor::RequiredArgumentMissingError, "
|
91
|
+
pacticipants_without_versions = selectors.select{ |s| s[:version].nil? && s[:latest].nil? }.collect{ |s| s[:pacticipant] }
|
92
|
+
raise ::Thor::RequiredArgumentMissingError, "The version must be specified using --version or --latest [TAG] for pacticipant #{pacticipants_without_versions.join(", ")}" if pacticipants_without_versions.any?
|
72
93
|
end
|
73
94
|
|
74
95
|
def publish_pacts pact_files
|
@@ -16,7 +16,24 @@ module PactBroker
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.massage_args argv
|
19
|
-
turn_muliple_tag_options_into_array(argv)
|
19
|
+
add_broker_config_from_environment_variables(turn_muliple_tag_options_into_array(argv))
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.add_broker_config_from_environment_variables argv
|
23
|
+
return argv if argv[0] == 'version' || argv[0] == 'help'
|
24
|
+
|
25
|
+
new_argv = add_option_from_environment_variable(argv, 'broker-base-url', 'b', 'PACT_BROKER_BASE_URL')
|
26
|
+
new_argv = add_option_from_environment_variable(new_argv, 'broker-username', 'u', 'PACT_BROKER_USERNAME')
|
27
|
+
add_option_from_environment_variable(new_argv, 'broker-password', 'p', 'PACT_BROKER_PASSWORD')
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.add_option_from_environment_variable argv, long_name, short_name, environment_variable_name
|
31
|
+
option_options = ["--#{long_name}", "--#{long_name.gsub('-','_')}", "-#{short_name}"]
|
32
|
+
if (argv & option_options).empty? && ENV[environment_variable_name]
|
33
|
+
argv + ["--#{long_name}", ENV[environment_variable_name]]
|
34
|
+
else
|
35
|
+
argv
|
36
|
+
end
|
20
37
|
end
|
21
38
|
|
22
39
|
# other task names, help, and the help shortcuts
|
@@ -9,6 +9,9 @@ module PactBroker
|
|
9
9
|
case option
|
10
10
|
when "--pacticipant", "-a"
|
11
11
|
versions << {}
|
12
|
+
when "--latest", "-l"
|
13
|
+
versions << {pacticipant: nil} unless versions.last
|
14
|
+
versions.last[:latest] = true
|
12
15
|
when /^\-/
|
13
16
|
nil
|
14
17
|
else
|
@@ -18,6 +21,9 @@ module PactBroker
|
|
18
21
|
when "--version", "-e"
|
19
22
|
versions << {pacticipant: nil} unless versions.last
|
20
23
|
versions.last[:version] = option
|
24
|
+
when "--latest", "-l"
|
25
|
+
versions << {pacticipant: nil} unless versions.last
|
26
|
+
versions.last[:tag] = option
|
21
27
|
end
|
22
28
|
end
|
23
29
|
last_flag = option if option.start_with?("-")
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'pact_broker/client/error'
|
2
|
+
require 'pact_broker/client/pact_broker_client'
|
3
|
+
require 'pact_broker/client/retry'
|
4
|
+
|
5
|
+
module PactBroker
|
6
|
+
module Client
|
7
|
+
class CreateTag
|
8
|
+
|
9
|
+
class Result
|
10
|
+
attr_reader :success, :message
|
11
|
+
|
12
|
+
def initialize success, message = nil
|
13
|
+
@success = success
|
14
|
+
@message = message
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.call(pact_broker_base_url, pacticipant_name, version, tags, pact_broker_client_options={})
|
19
|
+
new(pact_broker_base_url, pacticipant_name, version, tags, pact_broker_client_options).call
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize(pact_broker_base_url, pacticipant_name, version, tags, pact_broker_client_options)
|
23
|
+
@pact_broker_base_url = pact_broker_base_url
|
24
|
+
@pacticipant_name = pacticipant_name
|
25
|
+
@version = version
|
26
|
+
@tags = tags
|
27
|
+
@pact_broker_client_options = pact_broker_client_options
|
28
|
+
end
|
29
|
+
|
30
|
+
def call
|
31
|
+
tags.each do | tag |
|
32
|
+
# todo check that pacticipant exists first
|
33
|
+
$stdout.puts "Tagging #{pacticipant_name} version #{version} as #{tag}"
|
34
|
+
Retry.until_true do
|
35
|
+
pact_broker_client.pacticipants.versions.tag pacticipant: pacticipant_name, version: version, tag: tag
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
attr_reader :pact_broker_base_url, :pacticipant_name, :version, :tags, :pact_broker_client_options
|
43
|
+
|
44
|
+
def pact_broker_client
|
45
|
+
@pact_broker_client ||= PactBroker::Client::PactBrokerClient.new(base_url: pact_broker_base_url, client_options: pact_broker_client_options)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -25,7 +25,14 @@ module PactBroker
|
|
25
25
|
else
|
26
26
|
error_message = nil
|
27
27
|
begin
|
28
|
-
|
28
|
+
errors = JSON.parse(response.body)['errors']
|
29
|
+
error_message = if errors.is_a?(Array)
|
30
|
+
errors.join("\n")
|
31
|
+
elsif errors.is_a?(Hash)
|
32
|
+
errors.collect{ |key, value| "#{key}: #{value}" }.join("\n")
|
33
|
+
else
|
34
|
+
response.body
|
35
|
+
end
|
29
36
|
rescue
|
30
37
|
raise Error.new(response.body)
|
31
38
|
end
|
@@ -45,6 +52,8 @@ module PactBroker
|
|
45
52
|
selectors.collect do |selector|
|
46
53
|
{ pacticipant: selector[:pacticipant] }.tap do | hash |
|
47
54
|
hash[:version] = selector[:version] if selector[:version]
|
55
|
+
hash[:latest] = 'true' if selector[:latest]
|
56
|
+
hash[:tag] = selector[:tag] if selector[:tag]
|
48
57
|
end
|
49
58
|
end
|
50
59
|
end
|
@@ -22,7 +22,7 @@ module PactBroker
|
|
22
22
|
return yield
|
23
23
|
rescue RescuableError => e
|
24
24
|
tries += 1
|
25
|
-
$stderr.puts "Error making request - #{e.message}, attempt #{tries} of #{max_tries}"
|
25
|
+
$stderr.puts "Error making request - #{e.class} #{e.message} #{e.backtrace.find{|l| l.include?('pact_broker-client')}}, attempt #{tries} of #{max_tries}"
|
26
26
|
raise e if max_tries == tries
|
27
27
|
sleep options
|
28
28
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
describe "pact-broker create-version-tag" do
|
2
|
+
before(:all) do
|
3
|
+
@pipe = IO.popen("bundle exec pact-stub-service spec/pacts/pact_broker_client-pact_broker.json -p 5001")
|
4
|
+
sleep 2
|
5
|
+
end
|
6
|
+
|
7
|
+
context "when the version is successfully tagged" do
|
8
|
+
subject { `bundle exec bin/pact-broker create-version-tag -v --pacticipant Condor --version 1.3.0 --tag prod --broker-base-url http://localhost:5001` }
|
9
|
+
|
10
|
+
it "returns a success exit code" do
|
11
|
+
subject
|
12
|
+
expect($?.exitstatus).to eq 0
|
13
|
+
expect(subject).to include 'Tagging Condor version 1.3.0 as prod'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
after(:all) do
|
18
|
+
Process.kill 'KILL', @pipe.pid
|
19
|
+
end
|
20
|
+
end
|
@@ -36,11 +36,11 @@ module PactBroker
|
|
36
36
|
invoke_can_i_deploy
|
37
37
|
end
|
38
38
|
|
39
|
-
context "with a missing --version" do
|
39
|
+
context "with a missing --version and --latest" do
|
40
40
|
let(:version_selectors) { [{pacticipant: "Foo", version: nil}] }
|
41
41
|
|
42
42
|
it "raises an error" do
|
43
|
-
expect { invoke_can_i_deploy }.to raise_error Thor::RequiredArgumentMissingError,
|
43
|
+
expect { invoke_can_i_deploy }.to raise_error Thor::RequiredArgumentMissingError, /The version must be specified/
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -18,6 +18,14 @@ module PactBroker::Client::CLI
|
|
18
18
|
Delegate.call(options)
|
19
19
|
end
|
20
20
|
|
21
|
+
desc '', ''
|
22
|
+
method_option :broker_base_url, required: true, aliases: "-b"
|
23
|
+
method_option :broker_username, aliases: "-u"
|
24
|
+
method_option :broker_password, aliases: "-p"
|
25
|
+
def test_using_env_vars
|
26
|
+
Delegate.call(options)
|
27
|
+
end
|
28
|
+
|
21
29
|
default_command :test_default
|
22
30
|
end
|
23
31
|
|
@@ -29,6 +37,32 @@ module PactBroker::Client::CLI
|
|
29
37
|
TestThor.start(%w{test_multiple_options --multi one --multi two})
|
30
38
|
end
|
31
39
|
|
40
|
+
context "with broker configuration in the environment variables" do
|
41
|
+
before do
|
42
|
+
ENV['PACT_BROKER_BASE_URL'] = 'http://foo'
|
43
|
+
ENV['PACT_BROKER_USERNAME'] = 'username'
|
44
|
+
ENV['PACT_BROKER_PASSWORD'] = 'password'
|
45
|
+
end
|
46
|
+
|
47
|
+
it "populates the options from the environment variables" do
|
48
|
+
expect(Delegate).to receive(:call) do | options |
|
49
|
+
expect(options.broker_base_url).to eq 'http://foo'
|
50
|
+
expect(options.broker_username).to eq 'username'
|
51
|
+
expect(options.broker_password).to eq 'password'
|
52
|
+
end
|
53
|
+
TestThor.start(%w{test_using_env_vars})
|
54
|
+
end
|
55
|
+
|
56
|
+
it "does not override a value specifed on the command line" do
|
57
|
+
expect(Delegate).to receive(:call) do | options |
|
58
|
+
expect(options.broker_base_url).to eq 'http://bar'
|
59
|
+
expect(options.broker_username).to eq 'username'
|
60
|
+
expect(options.broker_password).to eq 'password'
|
61
|
+
end
|
62
|
+
TestThor.start(%w{test_using_env_vars --broker-base-url http://bar})
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
32
66
|
describe ".turn_muliple_tag_options_into_array" do
|
33
67
|
it "turns '--tag foo --tag bar' into '--tag foo bar'" do
|
34
68
|
input = %w{--ignore this --tag foo --tag bar --wiffle --that}
|
@@ -30,6 +30,12 @@ module PactBroker
|
|
30
30
|
],[
|
31
31
|
["--version", "1.2.3"],
|
32
32
|
[{ pacticipant: nil, version: "1.2.3" } ]
|
33
|
+
],[
|
34
|
+
["--pacticipant", "Foo", "--latest", "--pacticipant", "Bar"],
|
35
|
+
[{ pacticipant: "Foo", latest: true }, { pacticipant: "Bar" } ]
|
36
|
+
],[
|
37
|
+
["--pacticipant", "Foo", "--latest", "prod", "--pacticipant", "Bar"],
|
38
|
+
[{ pacticipant: "Foo", latest: true, tag: "prod"}, { pacticipant: "Bar" } ]
|
33
39
|
]
|
34
40
|
]
|
35
41
|
|
@@ -451,6 +451,102 @@
|
|
451
451
|
}
|
452
452
|
}
|
453
453
|
},
|
454
|
+
{
|
455
|
+
"description": "a request for the compatibility matrix for Foo version 1.2.3 and the latest prod version of Bar",
|
456
|
+
"providerState": "the pact for Foo version 1.2.3 has been successfully verified by Bar version 4.5.6 with tag prod, and 1.2.4 unsuccessfully by 9.9.9",
|
457
|
+
"request": {
|
458
|
+
"method": "get",
|
459
|
+
"path": "/matrix",
|
460
|
+
"query": "q[][pacticipant]=Foo&q[][version]=1.2.3&q[][pacticipant]=Bar&q[][latest]=true&q[][tag]=prod"
|
461
|
+
},
|
462
|
+
"response": {
|
463
|
+
"status": 200,
|
464
|
+
"headers": {
|
465
|
+
},
|
466
|
+
"body": {
|
467
|
+
"summary": {
|
468
|
+
"deployable": true,
|
469
|
+
"reason": "some text"
|
470
|
+
},
|
471
|
+
"matrix": [
|
472
|
+
{
|
473
|
+
"consumer": {
|
474
|
+
"name": "Foo",
|
475
|
+
"version": {
|
476
|
+
"number": "4"
|
477
|
+
}
|
478
|
+
},
|
479
|
+
"provider": {
|
480
|
+
"name": "Bar",
|
481
|
+
"version": {
|
482
|
+
"number": "5"
|
483
|
+
}
|
484
|
+
},
|
485
|
+
"verificationResult": {
|
486
|
+
"verifiedAt": "2017-10-10T12:49:04+11:00",
|
487
|
+
"success": true
|
488
|
+
},
|
489
|
+
"pact": {
|
490
|
+
"createdAt": "2017-10-10T12:49:04+11:00"
|
491
|
+
}
|
492
|
+
}
|
493
|
+
]
|
494
|
+
},
|
495
|
+
"matchingRules": {
|
496
|
+
"$.body": {
|
497
|
+
"match": "type"
|
498
|
+
}
|
499
|
+
}
|
500
|
+
}
|
501
|
+
},
|
502
|
+
{
|
503
|
+
"description": "a request for the compatibility matrix for Foo version 1.2.3 and the latest version of Bar",
|
504
|
+
"providerState": "the pact for Foo version 1.2.3 has been successfully verified by Bar version 4.5.6, and 1.2.4 unsuccessfully by 9.9.9",
|
505
|
+
"request": {
|
506
|
+
"method": "get",
|
507
|
+
"path": "/matrix",
|
508
|
+
"query": "q[][pacticipant]=Foo&q[][version]=1.2.4&q[][pacticipant]=Bar&q[][latest]=true"
|
509
|
+
},
|
510
|
+
"response": {
|
511
|
+
"status": 200,
|
512
|
+
"headers": {
|
513
|
+
},
|
514
|
+
"body": {
|
515
|
+
"summary": {
|
516
|
+
"deployable": true,
|
517
|
+
"reason": "some text"
|
518
|
+
},
|
519
|
+
"matrix": [
|
520
|
+
{
|
521
|
+
"consumer": {
|
522
|
+
"name": "Foo",
|
523
|
+
"version": {
|
524
|
+
"number": "4"
|
525
|
+
}
|
526
|
+
},
|
527
|
+
"provider": {
|
528
|
+
"name": "Bar",
|
529
|
+
"version": {
|
530
|
+
"number": "5"
|
531
|
+
}
|
532
|
+
},
|
533
|
+
"verificationResult": {
|
534
|
+
"verifiedAt": "2017-10-10T12:49:04+11:00",
|
535
|
+
"success": true
|
536
|
+
},
|
537
|
+
"pact": {
|
538
|
+
"createdAt": "2017-10-10T12:49:04+11:00"
|
539
|
+
}
|
540
|
+
}
|
541
|
+
]
|
542
|
+
},
|
543
|
+
"matchingRules": {
|
544
|
+
"$.body": {
|
545
|
+
"match": "type"
|
546
|
+
}
|
547
|
+
}
|
548
|
+
}
|
549
|
+
},
|
454
550
|
{
|
455
551
|
"description": "a request to publish a pact",
|
456
552
|
"providerState": "the 'Pricing Service' already exists in the pact-broker",
|
@@ -186,6 +186,58 @@ module PactBroker::Client
|
|
186
186
|
expect(matrix[:matrix].size).to eq 1
|
187
187
|
end
|
188
188
|
end
|
189
|
+
|
190
|
+
context "when the latest version for a given tag is specified" do
|
191
|
+
before do
|
192
|
+
pact_broker.
|
193
|
+
given("the pact for Foo version 1.2.3 has been successfully verified by Bar version 4.5.6 with tag prod, and 1.2.4 unsuccessfully by 9.9.9").
|
194
|
+
upon_receiving("a request for the compatibility matrix for Foo version 1.2.3 and the latest prod version of Bar").
|
195
|
+
with(
|
196
|
+
method: :get,
|
197
|
+
path: "/matrix",
|
198
|
+
query: "q[][pacticipant]=Foo&q[][version]=1.2.3&q[][pacticipant]=Bar&q[][latest]=true&q[][tag]=prod"
|
199
|
+
).
|
200
|
+
will_respond_with(
|
201
|
+
status: 200,
|
202
|
+
headers: pact_broker_response_headers,
|
203
|
+
body: matrix_response_body
|
204
|
+
)
|
205
|
+
end
|
206
|
+
let(:matrix_row) { JSON.parse(File.read('spec/support/matrix.json'))['matrix'].first }
|
207
|
+
let(:selectors) { [{ pacticipant: "Foo", version: "1.2.3"}, { pacticipant: "Bar", latest: true, tag: 'prod' }] }
|
208
|
+
let(:options) { {} }
|
209
|
+
|
210
|
+
it "returns the matrix with the latest prod version of Bar" do
|
211
|
+
matrix = pact_broker_client.matrix.get(selectors, options)
|
212
|
+
expect(matrix[:matrix].size).to eq 1
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
context "when the latest version is specified" do
|
217
|
+
before do
|
218
|
+
pact_broker.
|
219
|
+
given("the pact for Foo version 1.2.3 has been successfully verified by Bar version 4.5.6, and 1.2.4 unsuccessfully by 9.9.9").
|
220
|
+
upon_receiving("a request for the compatibility matrix for Foo version 1.2.3 and the latest version of Bar").
|
221
|
+
with(
|
222
|
+
method: :get,
|
223
|
+
path: "/matrix",
|
224
|
+
query: "q[][pacticipant]=Foo&q[][version]=1.2.4&q[][pacticipant]=Bar&q[][latest]=true"
|
225
|
+
).
|
226
|
+
will_respond_with(
|
227
|
+
status: 200,
|
228
|
+
headers: pact_broker_response_headers,
|
229
|
+
body: matrix_response_body
|
230
|
+
)
|
231
|
+
end
|
232
|
+
let(:matrix_row) { JSON.parse(File.read('spec/support/matrix.json'))['matrix'].first }
|
233
|
+
let(:selectors) { [{ pacticipant: "Foo", version: "1.2.4"}, { pacticipant: "Bar", latest: true }] }
|
234
|
+
let(:options) { {} }
|
235
|
+
|
236
|
+
it "returns the matrix with the latest prod version of Bar" do
|
237
|
+
matrix = pact_broker_client.matrix.get(selectors, options)
|
238
|
+
expect(matrix[:matrix].size).to eq 1
|
239
|
+
end
|
240
|
+
end
|
189
241
|
end
|
190
242
|
end
|
191
243
|
end
|
data/spec/spec_helper.rb
CHANGED
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.11.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: 2017-
|
11
|
+
date: 2017-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -163,6 +163,7 @@ files:
|
|
163
163
|
- lib/pact_broker/client/cli/broker.rb
|
164
164
|
- lib/pact_broker/client/cli/custom_thor.rb
|
165
165
|
- lib/pact_broker/client/cli/version_selector_options_parser.rb
|
166
|
+
- lib/pact_broker/client/create_tag.rb
|
166
167
|
- lib/pact_broker/client/error.rb
|
167
168
|
- lib/pact_broker/client/git.rb
|
168
169
|
- lib/pact_broker/client/matrix.rb
|
@@ -186,6 +187,7 @@ files:
|
|
186
187
|
- script/publish-pact.sh
|
187
188
|
- script/release.sh
|
188
189
|
- spec/integration/can_i_deploy_spec.rb
|
190
|
+
- spec/integration/create_version_tag_spec.rb
|
189
191
|
- spec/lib/pact_broker/client/base_client_spec.rb
|
190
192
|
- spec/lib/pact_broker/client/can_i_deploy_spec.rb
|
191
193
|
- spec/lib/pact_broker/client/cli/broker_can_i_deploy_spec.rb
|
@@ -242,12 +244,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
242
244
|
version: '0'
|
243
245
|
requirements: []
|
244
246
|
rubyforge_project:
|
245
|
-
rubygems_version: 2.6.
|
247
|
+
rubygems_version: 2.6.11
|
246
248
|
signing_key:
|
247
249
|
specification_version: 4
|
248
250
|
summary: See description
|
249
251
|
test_files:
|
250
252
|
- spec/integration/can_i_deploy_spec.rb
|
253
|
+
- spec/integration/create_version_tag_spec.rb
|
251
254
|
- spec/lib/pact_broker/client/base_client_spec.rb
|
252
255
|
- spec/lib/pact_broker/client/can_i_deploy_spec.rb
|
253
256
|
- spec/lib/pact_broker/client/cli/broker_can_i_deploy_spec.rb
|