pact_broker-client 1.11.0 → 1.12.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 +14 -0
- data/README.md +101 -14
- data/lib/pact_broker/client/cli/broker.rb +2 -1
- data/lib/pact_broker/client/cli/can_i_deploy_long_desc.txt +31 -0
- data/lib/pact_broker/client/matrix.rb +3 -1
- data/lib/pact_broker/client/matrix/text_formatter.rb +9 -1
- data/lib/pact_broker/client/tasks/publication_task.rb +11 -3
- data/lib/pact_broker/client/version.rb +1 -1
- data/script/generate-cli-usage.sh +20 -0
- data/spec/lib/pact_broker/client/tasks/publication_task_spec.rb +18 -5
- data/spec/pacts/pact_broker_client-pact_broker.json +56 -8
- data/spec/service_providers/pact_broker_client_matrix_spec.rb +32 -27
- data/spec/support/matrix.txt +3 -3
- data/spec/support/matrix_error.txt +3 -3
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66e0409305fdcec099daca823e1cb127ef56081d
|
4
|
+
data.tar.gz: 810b2cd5e4f581e229104fb30cf9fddaf1387aa6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5d6208dedba22ebcbd587bf593d3ca626c54d60d3f3e0a5b3fc23c2d02b6d282e416ae024fdbad77ab1a0915602f3d715fb6ad04b59bcd17c579a249be47de2
|
7
|
+
data.tar.gz: 4b37910c9a784962d4f9e054d0308e13227f7a267e60c8e64f8803faf6a71cb7a1d215a4eb7b35300fef35f6437dcd229bc991af636e6e7cb1de2a89051b5639
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
<a name="v1.12.0"></a>
|
2
|
+
### v1.12.0 (2017-11-06)
|
3
|
+
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* **publish**
|
8
|
+
* expose tag_with_git_branch in rake publication task ([f28d9ad](/../../commit/f28d9ad))
|
9
|
+
|
10
|
+
* **can-i-deploy**
|
11
|
+
* shorten header names in text output ([89d5a04](/../../commit/89d5a04))
|
12
|
+
* support invocation with only one pacticipant/version provided ([3d799cc](/../../commit/3d799cc))
|
13
|
+
|
14
|
+
|
1
15
|
<a name="v1.11.0"></a>
|
2
16
|
### v1.11.0 (2017-11-01)
|
3
17
|
|
data/README.md
CHANGED
@@ -1,12 +1,106 @@
|
|
1
1
|
# Pact Broker Client
|
2
2
|
|
3
|
-
A client for the Pact Broker. Publishes pacts to, and retrieves pacts from, the pact broker.
|
3
|
+
A client for the Pact Broker. Publishes pacts to, and retrieves pacts from, the pact broker. The functionality is available via a CLI, or via Ruby configuration code.
|
4
4
|
|
5
5
|
[![Build Status](https://travis-ci.org/pact-foundation/pact_broker-client.svg?branch=master)](https://travis-ci.org/pact-foundation/pact_broker-client)
|
6
6
|
|
7
|
-
## Usage
|
7
|
+
## Usage - CLI
|
8
8
|
|
9
|
-
|
9
|
+
### publish
|
10
|
+
|
11
|
+
```
|
12
|
+
Usage:
|
13
|
+
pact-broker publish PACT_DIRS_OR_FILES ... -a, --consumer-app-version=CONSUMER_APP_VERSION -b, --broker-base-url=BROKER_BASE_URL
|
14
|
+
|
15
|
+
Options:
|
16
|
+
-a, --consumer-app-version=CONSUMER_APP_VERSION # The consumer application version
|
17
|
+
-b, --broker-base-url=BROKER_BASE_URL # The base URL of the Pact Broker
|
18
|
+
-u, [--broker-username=BROKER_USERNAME] # Pact Broker basic auth username
|
19
|
+
-p, [--broker-password=BROKER_PASSWORD] # Pact Broker basic auth password
|
20
|
+
-t, [--tag=TAG] # Tag name for consumer version. Can be specified multiple times.
|
21
|
+
-g, [--tag-with-git-branch], [--no-tag-with-git-branch] # Tag consumer version with the name of the current git branch. Default: false
|
22
|
+
-v, [--verbose], [--no-verbose] # Verbose output. Default: false
|
23
|
+
|
24
|
+
Publish pacts to a Pact Broker.
|
25
|
+
```
|
26
|
+
|
27
|
+
### create-version-tag
|
28
|
+
|
29
|
+
```
|
30
|
+
Usage:
|
31
|
+
pact-broker create-version-tag -a, --pacticipant=PACTICIPANT -b, --broker-base-url=BROKER_BASE_URL -e, --version=VERSION
|
32
|
+
|
33
|
+
Options:
|
34
|
+
-a, --pacticipant=PACTICIPANT # The pacticipant name
|
35
|
+
-e, --version=VERSION # The pacticipant version
|
36
|
+
-t, [--tag=TAG] # Tag name for pacticipant version. Can be specified multiple times.
|
37
|
+
-g, [--tag-with-git-branch], [--no-tag-with-git-branch] # Tag pacticipant version with the name of the current git branch. Default: false
|
38
|
+
-b, --broker-base-url=BROKER_BASE_URL # The base URL of the Pact Broker
|
39
|
+
-u, [--broker-username=BROKER_USERNAME] # Pact Broker basic auth username
|
40
|
+
-p, [--broker-password=BROKER_PASSWORD] # Pact Broker basic auth password
|
41
|
+
-v, [--verbose], [--no-verbose] # Verbose output. Default: false
|
42
|
+
|
43
|
+
Add a tag to a pacticipant version
|
44
|
+
```
|
45
|
+
|
46
|
+
### can-i-deploy
|
47
|
+
|
48
|
+
*This feature is in beta release, and backwards compatibility is NOT guaranteed.*
|
49
|
+
You will need the latest version of the Pact Broker for this feature to work.
|
50
|
+
|
51
|
+
```
|
52
|
+
Usage:
|
53
|
+
pact-broker can-i-deploy -a, --pacticipant=PACTICIPANT -b, --broker-base-url=BROKER_BASE_URL
|
54
|
+
|
55
|
+
Options:
|
56
|
+
-a, --pacticipant=PACTICIPANT # The pacticipant name. Use once for each pacticipant being checked.
|
57
|
+
-e, [--version=VERSION] # The pacticipant version. Must be entered after the --pacticipant that it relates to.
|
58
|
+
-l, [--latest=[TAG]] # Use the latest pacticipant version. Optionally specify a TAG to use the latest version with the specified tag.
|
59
|
+
-b, --broker-base-url=BROKER_BASE_URL # The base URL of the Pact Broker
|
60
|
+
-u, [--broker-username=BROKER_USERNAME] # Pact Broker basic auth username
|
61
|
+
-p, [--broker-password=BROKER_PASSWORD] # Pact Broker basic auth password
|
62
|
+
-o, [--output=OUTPUT] # json or table
|
63
|
+
# Default: table
|
64
|
+
-v, [--verbose], [--no-verbose] # Verbose output. Default: false
|
65
|
+
|
66
|
+
Description:
|
67
|
+
Returns exit code 0 or 1, indicating whether or not the specified pacticipant versions are compatible. Prints out the
|
68
|
+
relevant pact/verification details.
|
69
|
+
|
70
|
+
The environment variables PACT_BROKER_BASE_URL, PACT_BROKER_USERNAME and PACT_BROKER_PASSWORD may be used instead of
|
71
|
+
their respective command line options.
|
72
|
+
|
73
|
+
SCENARIOS
|
74
|
+
|
75
|
+
Check the status of the pacts for a pacticipant version:
|
76
|
+
|
77
|
+
$ pact-broker can-i-deploy --pacticipant PACTICIPANT --version VERSION --broker-base-url BROKER_BASE_URL
|
78
|
+
|
79
|
+
Check the status of the pacts for the latest pacticipant version:
|
80
|
+
|
81
|
+
$ pact-broker can-i-deploy --pacticipant PACTICIPANT --latest --broker-base-url BROKER_BASE_URL
|
82
|
+
|
83
|
+
Check the status of the pacts for the latest pacticipant version for a given tag:
|
84
|
+
|
85
|
+
$ pact-broker can-i-deploy --pacticipant PACTICIPANT --latest TAG --broker-base-url BROKER_BASE_URL
|
86
|
+
|
87
|
+
Check the status of the pacts between two (or more) specific pacticipant versions:
|
88
|
+
|
89
|
+
$ pact-broker can-i-deploy --pacticipant PACTICIPANT1 --version VERSION1 --pacticipant PACTICIPANT2 --version VERSION2
|
90
|
+
--broker-base-url BROKER_BASE_URL
|
91
|
+
|
92
|
+
Check the status of the pacts between the latest versions of two (or more) pacticipants:
|
93
|
+
|
94
|
+
$ pact-broker can-i-deploy --pacticipant PACTICIPANT1 --latest --pacticipant PACTICIPANT2 --latest --broker-base-url
|
95
|
+
BROKER
|
96
|
+
|
97
|
+
Check the status of the pacts between the latest versions of two (or more) pacticipants with a given tag:
|
98
|
+
|
99
|
+
$ pact-broker can-i-deploy --pacticipant PACTICIPANT1 --latest TAG1 --pacticipant PACTICIPANT2 --latest TAG2
|
100
|
+
--broker-base-url BROKER_BASE_URL
|
101
|
+
```
|
102
|
+
|
103
|
+
## Usage - Ruby
|
10
104
|
|
11
105
|
### Consumer
|
12
106
|
|
@@ -25,23 +119,14 @@ PactBroker::Client::PublicationTask.new do | task |
|
|
25
119
|
require 'my_consumer/version'
|
26
120
|
task.consumer_version = MyConsumer::VERSION
|
27
121
|
task.pattern = 'custom/path/to/pacts/*.json' # optional, default value is 'spec/pacts/*.json'
|
28
|
-
task.pact_broker_base_url = "http://pact-broker
|
122
|
+
task.pact_broker_base_url = "http://pact-broker"
|
123
|
+
task.tag_with_git_branch = true|false # STRONGLY RECOMMENDED as it will greatly assist with your pact workflow. Optional, will merge result with other specified task.tags
|
29
124
|
task.tags = ["dev"] # optional
|
30
125
|
task.pact_broker_basic_auth = { username: 'basic_auth_user', password: 'basic_auth_pass'} # optional
|
31
126
|
task.write_method = :merge # optional, this will merge the published pact into an existing pact rather than overwriting it if one exists. Not recommended, as it makes a mulch of the workflow on the broker.
|
32
127
|
end
|
33
128
|
```
|
34
129
|
|
35
|
-
## Using tags
|
36
|
-
|
37
|
-
Tags enable you to test different versions of your consumer and provider against each other (eg. `head` and `prod`) and to use pacts on feature branches without breaking your main line of development. You can read more about using tags on the Pact broker [wiki][wiki-tags].
|
38
|
-
|
39
|
-
If you want to use the git branch name as the tag name, use:
|
40
|
-
|
41
|
-
```ruby
|
42
|
-
task.tag = `git rev-parse --abbrev-ref HEAD`.strip
|
43
|
-
```
|
44
|
-
|
45
130
|
```bash
|
46
131
|
# In CI script
|
47
132
|
|
@@ -64,4 +149,6 @@ Pact.service_provider "My Provider" do
|
|
64
149
|
end
|
65
150
|
```
|
66
151
|
|
152
|
+
|
153
|
+
|
67
154
|
[wiki-tags]: https://github.com/pact-foundation/pact_broker/wiki/Using-tags
|
@@ -15,7 +15,8 @@ module PactBroker
|
|
15
15
|
class PactPublicationError < ::Thor::Error; end
|
16
16
|
|
17
17
|
class Broker < CustomThor
|
18
|
-
desc 'can-i-deploy',
|
18
|
+
desc 'can-i-deploy', ''
|
19
|
+
long_desc File.read(File.join(File.dirname(__FILE__), 'can_i_deploy_long_desc.txt'))
|
19
20
|
|
20
21
|
method_option :pacticipant, required: true, aliases: "-a", desc: "The pacticipant name. Use once for each pacticipant being checked."
|
21
22
|
method_option :version, required: false, aliases: "-e", desc: "The pacticipant version. Must be entered after the --pacticipant that it relates to."
|
@@ -0,0 +1,31 @@
|
|
1
|
+
Returns exit code 0 or 1, indicating whether or not the specified pacticipant versions are compatible. Prints out the relevant pact/verification details.
|
2
|
+
|
3
|
+
WARNING! This feature is in beta release, and backwards compatibility is NOT guaranteed. You will need the latest version of the Pact Broker for this feature to work.
|
4
|
+
|
5
|
+
The environment variables PACT_BROKER_BASE_URL_BASE_URL, PACT_BROKER_BASE_URL_USERNAME and PACT_BROKER_BASE_URL_PASSWORD may be used instead of their respective command line options.
|
6
|
+
|
7
|
+
SCENARIOS
|
8
|
+
|
9
|
+
Check the status of the pacts for a pacticipant version:
|
10
|
+
|
11
|
+
$ pact-broker can-i-deploy --pacticipant PACTICIPANT --version VERSION --broker-base-url BROKER_BASE_URL
|
12
|
+
|
13
|
+
Check the status of the pacts for the latest pacticipant version:
|
14
|
+
|
15
|
+
$ pact-broker can-i-deploy --pacticipant PACTICIPANT --latest --broker-base-url BROKER_BASE_URL
|
16
|
+
|
17
|
+
Check the status of the pacts for the latest pacticipant version for a given tag:
|
18
|
+
|
19
|
+
$ pact-broker can-i-deploy --pacticipant PACTICIPANT --latest TAG --broker-base-url BROKER_BASE_URL
|
20
|
+
|
21
|
+
Check the status of the pacts between two (or more) specific pacticipant versions:
|
22
|
+
|
23
|
+
$ pact-broker can-i-deploy --pacticipant PACTICIPANT1 --version VERSION1 --pacticipant PACTICIPANT2 --version VERSION2 --broker-base-url BROKER_BASE_URL
|
24
|
+
|
25
|
+
Check the status of the pacts between the latest versions of two (or more) pacticipants:
|
26
|
+
|
27
|
+
$ pact-broker can-i-deploy --pacticipant PACTICIPANT1 --latest --pacticipant PACTICIPANT2 --latest --broker-base-url BROKER_BASE_URL
|
28
|
+
|
29
|
+
Check the status of the pacts between the latest versions of two (or more) pacticipants with a given tag:
|
30
|
+
|
31
|
+
$ pact-broker can-i-deploy --pacticipant PACTICIPANT1 --latest TAG1 --pacticipant PACTICIPANT2 --latest TAG2 --broker-base-url BROKER_BASE_URL
|
@@ -4,8 +4,10 @@ module PactBroker
|
|
4
4
|
module Client
|
5
5
|
class Matrix < BaseClient
|
6
6
|
def get selectors, options = {}
|
7
|
+
latestby = selectors.size == 1 ? 'cvp' : 'cvpv'
|
7
8
|
query = {
|
8
|
-
q: convert_selector_hashes_to_params(selectors)
|
9
|
+
q: convert_selector_hashes_to_params(selectors),
|
10
|
+
latestby: latestby
|
9
11
|
}.merge(query_options(options))
|
10
12
|
response = self.class.get("/matrix", query: query, headers: default_get_headers)
|
11
13
|
$stdout.puts("DEBUG: Response headers #{response.headers}") if verbose?
|
@@ -7,6 +7,14 @@ module PactBroker
|
|
7
7
|
|
8
8
|
Line = Struct.new(:consumer, :consumer_version, :provider, :provider_version, :success)
|
9
9
|
|
10
|
+
OPTIONS = [
|
11
|
+
{ consumer: {} },
|
12
|
+
{ consumer_version: {display_name: 'C.VERSION'} },
|
13
|
+
{ provider: {} },
|
14
|
+
{ provider_version: {display_name: 'P.VERSION'} },
|
15
|
+
{ success: {display_name: 'SUCCESS?'} }
|
16
|
+
]
|
17
|
+
|
10
18
|
def self.call(matrix)
|
11
19
|
data = matrix[:matrix].collect do | line |
|
12
20
|
Line.new(
|
@@ -18,7 +26,7 @@ module PactBroker
|
|
18
26
|
)
|
19
27
|
end
|
20
28
|
|
21
|
-
printer = TablePrint::Printer.new(data)
|
29
|
+
printer = TablePrint::Printer.new(data, OPTIONS)
|
22
30
|
printer.table_print
|
23
31
|
end
|
24
32
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'rake/tasklib'
|
2
|
+
require 'pact_broker/client/git'
|
2
3
|
|
3
4
|
=begin
|
4
5
|
require pact_broker/client/tasks
|
@@ -7,7 +8,8 @@ PactBroker::Client::PublicationTask.new do | task |
|
|
7
8
|
require 'consumer/version'
|
8
9
|
task.pact_broker_base_url = 'http://pact-broker'
|
9
10
|
task.consumer_version = Consumer::VERSION
|
10
|
-
task.
|
11
|
+
task.tags = ["dev"]
|
12
|
+
task.tag_with_git_branch = true
|
11
13
|
end
|
12
14
|
|
13
15
|
=end
|
@@ -16,7 +18,8 @@ module PactBroker
|
|
16
18
|
module Client
|
17
19
|
class PublicationTask < ::Rake::TaskLib
|
18
20
|
|
19
|
-
attr_accessor :pattern, :pact_broker_base_url, :consumer_version, :tag, :write_method, :pact_broker_basic_auth
|
21
|
+
attr_accessor :pattern, :pact_broker_base_url, :consumer_version, :tag, :write_method, :tag_with_git_branch, :pact_broker_basic_auth
|
22
|
+
alias_method :tags=, :tag=
|
20
23
|
alias_method :tags, :tag
|
21
24
|
|
22
25
|
def initialize name = nil, &block
|
@@ -36,7 +39,7 @@ module PactBroker
|
|
36
39
|
require 'pact_broker/client/publish_pacts'
|
37
40
|
basic_auth_client_options = pact_broker_basic_auth ? {basic_auth: pact_broker_basic_auth} : {}
|
38
41
|
pact_broker_client_options = basic_auth_client_options.merge(write_method ? {write: write_method} : {})
|
39
|
-
success = PactBroker::Client::PublishPacts.new(pact_broker_base_url, FileList[pattern], consumer_version,
|
42
|
+
success = PactBroker::Client::PublishPacts.new(pact_broker_base_url, FileList[pattern], consumer_version, all_tags, pact_broker_client_options).call
|
40
43
|
raise "One or more pacts failed to be published" unless success
|
41
44
|
end
|
42
45
|
end
|
@@ -46,6 +49,11 @@ module PactBroker
|
|
46
49
|
@name ? "publish:#{@name}" : "publish"
|
47
50
|
end
|
48
51
|
|
52
|
+
def all_tags
|
53
|
+
t = [*tags]
|
54
|
+
t << PactBroker::Client::Git.branch if tag_with_git_branch
|
55
|
+
t.compact.uniq
|
56
|
+
end
|
49
57
|
end
|
50
58
|
end
|
51
59
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
echo '### publish'
|
2
|
+
echo ''
|
3
|
+
echo '```'
|
4
|
+
echo "$(bundle exec bin/pact-broker help publish)"
|
5
|
+
echo '```'
|
6
|
+
echo ''
|
7
|
+
echo '### create-version-tag'
|
8
|
+
echo ''
|
9
|
+
echo '```'
|
10
|
+
echo "$(bundle exec bin/pact-broker help create-version-tag)"
|
11
|
+
echo '```'
|
12
|
+
echo ''
|
13
|
+
echo '### can-i-deploy'
|
14
|
+
echo ''
|
15
|
+
echo '*This feature is in beta release, and backwards compatibility is NOT guaranteed.*'
|
16
|
+
echo 'You will need the latest version of the Pact Broker for this feature to work.'
|
17
|
+
echo ''
|
18
|
+
echo '```'
|
19
|
+
echo "$(bundle exec bin/pact-broker help can-i-deploy)"
|
20
|
+
echo '```'
|
@@ -10,12 +10,13 @@ module PactBroker::Client
|
|
10
10
|
@consumer_version = "1.2.3"
|
11
11
|
end
|
12
12
|
|
13
|
-
let(:publish_pacts) { instance_double("PactBroker::ClientSupport::PublishPacts")}
|
13
|
+
let(:publish_pacts) { instance_double("PactBroker::ClientSupport::PublishPacts", call: true)}
|
14
14
|
let(:pact_file_list) { ['spec/pact/consumer-provider.json'] }
|
15
15
|
|
16
16
|
before do
|
17
17
|
allow(PactBroker::Client::PublishPacts).to receive(:new).and_return(publish_pacts)
|
18
18
|
allow(FileList).to receive(:[]).with(pattern).and_return(pact_file_list)
|
19
|
+
allow(PactBroker::Client::Git).to receive(:branch).and_return('foo')
|
19
20
|
end
|
20
21
|
|
21
22
|
let(:pattern) { "spec/pacts/*.json" }
|
@@ -59,6 +60,22 @@ module PactBroker::Client
|
|
59
60
|
end
|
60
61
|
end
|
61
62
|
|
63
|
+
context "when tag_with_git_branch is true" do
|
64
|
+
before :all do
|
65
|
+
PactBroker::Client::PublicationTask.new(:git_branch) do | task |
|
66
|
+
task.consumer_version = '1.2.3'
|
67
|
+
task.tag_with_git_branch = true
|
68
|
+
task.tags = ['bar']
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
it "invokes PublishPacts with the git branch name as a tag" do
|
73
|
+
expect(PactBroker::Client::PublishPacts).to receive(:new).with(anything, anything, anything, ['bar', 'foo'], anything).and_return(publish_pacts)
|
74
|
+
|
75
|
+
Rake::Task['pact:publish:git_branch'].execute
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
62
79
|
describe "custom task" do
|
63
80
|
|
64
81
|
before :all do
|
@@ -85,7 +102,6 @@ module PactBroker::Client
|
|
85
102
|
end
|
86
103
|
|
87
104
|
describe "timing of block execution" do
|
88
|
-
|
89
105
|
before :all do
|
90
106
|
PactBroker::Client::PublicationTask.new(:exception) do | task |
|
91
107
|
raise 'A contrived exception'
|
@@ -96,8 +112,5 @@ module PactBroker::Client
|
|
96
112
|
expect{ Rake::Task['pact:publish:exception'].execute }.to raise_error 'A contrived exception'
|
97
113
|
end
|
98
114
|
end
|
99
|
-
|
100
|
-
|
101
115
|
end
|
102
|
-
|
103
116
|
end
|
@@ -192,7 +192,7 @@
|
|
192
192
|
"request": {
|
193
193
|
"method": "get",
|
194
194
|
"path": "/matrix",
|
195
|
-
"query": "q[][pacticipant]=Foo&q[][version]=1.2.3&q[][pacticipant]=Bar&q[][version]=4.5.6"
|
195
|
+
"query": "q[][pacticipant]=Foo&q[][version]=1.2.3&q[][pacticipant]=Bar&q[][version]=4.5.6&latestby=cvpv"
|
196
196
|
},
|
197
197
|
"response": {
|
198
198
|
"status": 200,
|
@@ -240,7 +240,55 @@
|
|
240
240
|
"request": {
|
241
241
|
"method": "get",
|
242
242
|
"path": "/matrix",
|
243
|
-
"query": "q[][pacticipant]=Foo%20Thing&q[][version]=1.2.3&q[][pacticipant]=Bar&q[][version]=4.5.6"
|
243
|
+
"query": "q[][pacticipant]=Foo%20Thing&q[][version]=1.2.3&q[][pacticipant]=Bar&q[][version]=4.5.6&latestby=cvpv"
|
244
|
+
},
|
245
|
+
"response": {
|
246
|
+
"status": 200,
|
247
|
+
"headers": {
|
248
|
+
},
|
249
|
+
"body": {
|
250
|
+
"summary": {
|
251
|
+
"deployable": true,
|
252
|
+
"reason": "some text"
|
253
|
+
},
|
254
|
+
"matrix": [
|
255
|
+
{
|
256
|
+
"consumer": {
|
257
|
+
"name": "Foo",
|
258
|
+
"version": {
|
259
|
+
"number": "4"
|
260
|
+
}
|
261
|
+
},
|
262
|
+
"provider": {
|
263
|
+
"name": "Bar",
|
264
|
+
"version": {
|
265
|
+
"number": "5"
|
266
|
+
}
|
267
|
+
},
|
268
|
+
"verificationResult": {
|
269
|
+
"verifiedAt": "2017-10-10T12:49:04+11:00",
|
270
|
+
"success": true
|
271
|
+
},
|
272
|
+
"pact": {
|
273
|
+
"createdAt": "2017-10-10T12:49:04+11:00"
|
274
|
+
}
|
275
|
+
}
|
276
|
+
]
|
277
|
+
},
|
278
|
+
"matchingRules": {
|
279
|
+
"$.body": {
|
280
|
+
"match": "type"
|
281
|
+
}
|
282
|
+
}
|
283
|
+
}
|
284
|
+
},
|
285
|
+
{
|
286
|
+
"description": "a request for the compatibility matrix where only the version of Foo is specified",
|
287
|
+
"providerState": "the pact for Foo version 1.2.3 has been verified by Bar version 4.5.6 and version 5.6.7",
|
288
|
+
"request": {
|
289
|
+
"method": "get",
|
290
|
+
"path": "/matrix",
|
291
|
+
"query": "q[][pacticipant]=Foo&q[][version]=1.2.3&latestby=cvp"
|
244
292
|
},
|
245
293
|
"response": {
|
246
294
|
"status": 200,
|
@@ -288,7 +336,7 @@
|
|
288
336
|
"request": {
|
289
337
|
"method": "get",
|
290
338
|
"path": "/matrix",
|
291
|
-
"query": "q[][pacticipant]=Foo&q[][version]=1.2.3&q[][pacticipant]=Bar&q[][version]=9.9.9"
|
339
|
+
"query": "q[][pacticipant]=Foo&q[][version]=1.2.3&q[][pacticipant]=Bar&q[][version]=9.9.9&latestby=cvpv"
|
292
340
|
},
|
293
341
|
"response": {
|
294
342
|
"status": 400,
|
@@ -314,7 +362,7 @@
|
|
314
362
|
"request": {
|
315
363
|
"method": "get",
|
316
364
|
"path": "/matrix",
|
317
|
-
"query": "q[][pacticipant]=Wiffle&q[][version]=1.2.3&q[][pacticipant]=Meep&q[][version]=9.9.9"
|
365
|
+
"query": "q[][pacticipant]=Wiffle&q[][version]=1.2.3&q[][pacticipant]=Meep&q[][version]=9.9.9&latestby=cvpv"
|
318
366
|
},
|
319
367
|
"response": {
|
320
368
|
"status": 400,
|
@@ -341,7 +389,7 @@
|
|
341
389
|
"request": {
|
342
390
|
"method": "get",
|
343
391
|
"path": "/matrix",
|
344
|
-
"query": "q[][pacticipant]=Foo&q[][pacticipant]=Bar"
|
392
|
+
"query": "q[][pacticipant]=Foo&q[][pacticipant]=Bar&latestby=cvpv"
|
345
393
|
},
|
346
394
|
"response": {
|
347
395
|
"status": 200,
|
@@ -409,7 +457,7 @@
|
|
409
457
|
"request": {
|
410
458
|
"method": "get",
|
411
459
|
"path": "/matrix",
|
412
|
-
"query": "q[][pacticipant]=Foo&q[][pacticipant]=Bar&success[]=true"
|
460
|
+
"query": "q[][pacticipant]=Foo&q[][pacticipant]=Bar&latestby=cvpv&success[]=true"
|
413
461
|
},
|
414
462
|
"response": {
|
415
463
|
"status": 200,
|
@@ -457,7 +505,7 @@
|
|
457
505
|
"request": {
|
458
506
|
"method": "get",
|
459
507
|
"path": "/matrix",
|
460
|
-
"query": "q[][pacticipant]=Foo&q[][version]=1.2.3&q[][pacticipant]=Bar&q[][latest]=true&q[][tag]=prod"
|
508
|
+
"query": "q[][pacticipant]=Foo&q[][version]=1.2.3&q[][pacticipant]=Bar&q[][latest]=true&q[][tag]=prod&latestby=cvpv"
|
461
509
|
},
|
462
510
|
"response": {
|
463
511
|
"status": 200,
|
@@ -505,7 +553,7 @@
|
|
505
553
|
"request": {
|
506
554
|
"method": "get",
|
507
555
|
"path": "/matrix",
|
508
|
-
"query": "q[][pacticipant]=Foo&q[][version]=1.2.4&q[][pacticipant]=Bar&q[][latest]=true"
|
556
|
+
"query": "q[][pacticipant]=Foo&q[][version]=1.2.4&q[][pacticipant]=Bar&q[][latest]=true&latestby=cvpv"
|
509
557
|
},
|
510
558
|
"response": {
|
511
559
|
"status": 200,
|
@@ -19,7 +19,7 @@ module PactBroker::Client
|
|
19
19
|
with(
|
20
20
|
method: :get,
|
21
21
|
path: "/matrix",
|
22
|
-
query: "q[][pacticipant]=Foo&q[][version]=1.2.3&q[][pacticipant]=Bar&q[][version]=4.5.6"
|
22
|
+
query: "q[][pacticipant]=Foo&q[][version]=1.2.3&q[][pacticipant]=Bar&q[][version]=4.5.6&latestby=cvpv"
|
23
23
|
).
|
24
24
|
will_respond_with(
|
25
25
|
status: 200,
|
@@ -42,7 +42,7 @@ module PactBroker::Client
|
|
42
42
|
with(
|
43
43
|
method: :get,
|
44
44
|
path: "/matrix",
|
45
|
-
query: "q[][pacticipant]=Foo%20Thing&q[][version]=1.2.3&q[][pacticipant]=Bar&q[][version]=4.5.6"
|
45
|
+
query: "q[][pacticipant]=Foo%20Thing&q[][version]=1.2.3&q[][pacticipant]=Bar&q[][version]=4.5.6&latestby=cvpv"
|
46
46
|
).
|
47
47
|
will_respond_with(
|
48
48
|
status: 200,
|
@@ -59,25 +59,30 @@ module PactBroker::Client
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
62
|
+
context "with only one version selector" do
|
63
|
+
before do
|
64
|
+
pact_broker.
|
65
|
+
given("the pact for Foo version 1.2.3 has been verified by Bar version 4.5.6 and version 5.6.7").
|
66
|
+
upon_receiving("a request for the compatibility matrix where only the version of Foo is specified").
|
67
|
+
with(
|
68
|
+
method: :get,
|
69
|
+
path: "/matrix",
|
70
|
+
query: "q[][pacticipant]=Foo&q[][version]=1.2.3&latestby=cvp"
|
71
|
+
).
|
72
|
+
will_respond_with(
|
73
|
+
status: 200,
|
74
|
+
headers: pact_broker_response_headers,
|
75
|
+
body: matrix_response_body
|
76
|
+
)
|
77
|
+
end
|
78
|
+
|
79
|
+
let(:selectors) { [{ pacticipant: "Foo", version: "1.2.3" }] }
|
80
|
+
|
81
|
+
it 'returns the row with the lastest verification for version 1.2.3' do
|
82
|
+
matrix = pact_broker_client.matrix.get(selectors)
|
83
|
+
expect(matrix[:matrix].size).to eq 1
|
84
|
+
end
|
85
|
+
end
|
81
86
|
|
82
87
|
context "when one or more of the versions does not exist" do
|
83
88
|
before do
|
@@ -87,7 +92,7 @@ module PactBroker::Client
|
|
87
92
|
with(
|
88
93
|
method: :get,
|
89
94
|
path: "/matrix",
|
90
|
-
query: "q[][pacticipant]=Foo&q[][version]=1.2.3&q[][pacticipant]=Bar&q[][version]=9.9.9"
|
95
|
+
query: "q[][pacticipant]=Foo&q[][version]=1.2.3&q[][pacticipant]=Bar&q[][version]=9.9.9&latestby=cvpv"
|
91
96
|
).
|
92
97
|
will_respond_with(
|
93
98
|
status: 400,
|
@@ -114,7 +119,7 @@ module PactBroker::Client
|
|
114
119
|
with(
|
115
120
|
method: :get,
|
116
121
|
path: "/matrix",
|
117
|
-
query: "q[][pacticipant]=Wiffle&q[][version]=1.2.3&q[][pacticipant]=Meep&q[][version]=9.9.9"
|
122
|
+
query: "q[][pacticipant]=Wiffle&q[][version]=1.2.3&q[][pacticipant]=Meep&q[][version]=9.9.9&latestby=cvpv"
|
118
123
|
).
|
119
124
|
will_respond_with(
|
120
125
|
status: 400,
|
@@ -142,7 +147,7 @@ module PactBroker::Client
|
|
142
147
|
with(
|
143
148
|
method: :get,
|
144
149
|
path: "/matrix",
|
145
|
-
query: "q[][pacticipant]=Foo&q[][pacticipant]=Bar"
|
150
|
+
query: "q[][pacticipant]=Foo&q[][pacticipant]=Bar&latestby=cvpv"
|
146
151
|
).
|
147
152
|
will_respond_with(
|
148
153
|
status: 200,
|
@@ -169,7 +174,7 @@ module PactBroker::Client
|
|
169
174
|
with(
|
170
175
|
method: :get,
|
171
176
|
path: "/matrix",
|
172
|
-
query: "q[][pacticipant]=Foo&q[][pacticipant]=Bar&success[]=true"
|
177
|
+
query: "q[][pacticipant]=Foo&q[][pacticipant]=Bar&latestby=cvpv&success[]=true"
|
173
178
|
).
|
174
179
|
will_respond_with(
|
175
180
|
status: 200,
|
@@ -195,7 +200,7 @@ module PactBroker::Client
|
|
195
200
|
with(
|
196
201
|
method: :get,
|
197
202
|
path: "/matrix",
|
198
|
-
query: "q[][pacticipant]=Foo&q[][version]=1.2.3&q[][pacticipant]=Bar&q[][latest]=true&q[][tag]=prod"
|
203
|
+
query: "q[][pacticipant]=Foo&q[][version]=1.2.3&q[][pacticipant]=Bar&q[][latest]=true&q[][tag]=prod&latestby=cvpv"
|
199
204
|
).
|
200
205
|
will_respond_with(
|
201
206
|
status: 200,
|
@@ -221,7 +226,7 @@ module PactBroker::Client
|
|
221
226
|
with(
|
222
227
|
method: :get,
|
223
228
|
path: "/matrix",
|
224
|
-
query: "q[][pacticipant]=Foo&q[][version]=1.2.4&q[][pacticipant]=Bar&q[][latest]=true"
|
229
|
+
query: "q[][pacticipant]=Foo&q[][version]=1.2.4&q[][pacticipant]=Bar&q[][latest]=true&latestby=cvpv"
|
225
230
|
).
|
226
231
|
will_respond_with(
|
227
232
|
status: 200,
|
data/spec/support/matrix.txt
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
CONSUMER |
|
2
|
-
|
3
|
-
Foo | 4
|
1
|
+
CONSUMER | C.VERSION | PROVIDER | P.VERSION | SUCCESS?
|
2
|
+
---------|-----------|----------|-----------|---------
|
3
|
+
Foo | 4 | Bar | 5 | true
|
@@ -1,3 +1,3 @@
|
|
1
|
-
CONSUMER |
|
2
|
-
|
3
|
-
??? | ???
|
1
|
+
CONSUMER | C.VERSION | PROVIDER | P.VERSION | SUCCESS?
|
2
|
+
---------|-----------|----------|-----------|---------
|
3
|
+
??? | ??? | ??? | ??? | ???
|
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.12.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-
|
11
|
+
date: 2017-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -161,6 +161,7 @@ files:
|
|
161
161
|
- lib/pact_broker/client/base_client.rb
|
162
162
|
- lib/pact_broker/client/can_i_deploy.rb
|
163
163
|
- lib/pact_broker/client/cli/broker.rb
|
164
|
+
- lib/pact_broker/client/cli/can_i_deploy_long_desc.txt
|
164
165
|
- lib/pact_broker/client/cli/custom_thor.rb
|
165
166
|
- lib/pact_broker/client/cli/version_selector_options_parser.rb
|
166
167
|
- lib/pact_broker/client/create_tag.rb
|
@@ -184,6 +185,7 @@ files:
|
|
184
185
|
- lib/pact_broker/client/versions.rb
|
185
186
|
- lib/pact_broker_client.rb
|
186
187
|
- pact-broker-client.gemspec
|
188
|
+
- script/generate-cli-usage.sh
|
187
189
|
- script/publish-pact.sh
|
188
190
|
- script/release.sh
|
189
191
|
- spec/integration/can_i_deploy_spec.rb
|