Skip to content

Commit

Permalink
feat(can-i-deploy): use array of query params for matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Oct 27, 2017
1 parent 003e305 commit 314e2e2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions lib/pact_broker/client/matrix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Client
class Matrix < BaseClient
def get selectors
query = convert_selector_hashes_to_params(selectors)
response = self.class.get("/matrix", query: query, headers: default_get_headers)
response = self.class.get("/matrix", query: {q: query}, headers: default_get_headers)
$stdout.puts("DEBUG: Response headers #{response.headers}") if verbose?
$stdout.puts("DEBUG: Response body #{response}") if verbose?
response = handle_response(response) do
Expand All @@ -32,7 +32,7 @@ def handle_response response
end

def convert_selector_hashes_to_params(selectors)
selectors.collect{ |selector| ["pacticipant[]=#{encode_query_param(selector[:name])}&version[]=#{encode_query_param(selector[:version])}"] }.join("&")
selectors.collect{ |selector| {pacticipant: selector[:name], version: selector[:version]} }
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/pacts/pact_broker_client-pact_broker.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
"request": {
"method": "get",
"path": "/matrix",
"query": "pacticipant[]=Foo&version[]=1.2.3&pacticipant[]=Bar&version[]=4.5.6"
"query": "q[][pacticipant]=Foo&q[][version]=1.2.3&q[][pacticipant]=Bar&q[][version]=4.5.6"
},
"response": {
"status": 200,
Expand Down Expand Up @@ -246,7 +246,7 @@
"request": {
"method": "get",
"path": "/matrix",
"query": "pacticipant[]=Foo+Thing&version[]=1.2.3&pacticipant[]=Bar&version[]=4.5.6"
"query": "q[][pacticipant]=Foo%20Thing&q[][version]=1.2.3&q[][pacticipant]=Bar&q[][version]=4.5.6"
},
"response": {
"status": 200,
Expand Down Expand Up @@ -288,7 +288,7 @@
"request": {
"method": "get",
"path": "/matrix",
"query": "pacticipant[]=Foo&version[]=1.2.3&pacticipant[]=Bar&version[]=9.9.9"
"query": "q[][pacticipant]=Foo&q[][version]=1.2.3&q[][pacticipant]=Bar&q[][version]=9.9.9"
},
"response": {
"status": 400,
Expand All @@ -308,7 +308,7 @@
"request": {
"method": "get",
"path": "/matrix",
"query": "pacticipant[]=Foo&version[]=1.2.3&pacticipant[]=Bar&version[]=9.9.9"
"query": "q[][pacticipant]=Foo&q[][version]=1.2.3&q[][pacticipant]=Bar&q[][version]=9.9.9"
},
"response": {
"status": 400,
Expand Down
8 changes: 4 additions & 4 deletions spec/service_providers/pact_broker_client_matrix_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module PactBroker::Client
with(
method: :get,
path: "/matrix",
query: "pacticipant[]=Foo&version[]=1.2.3&pacticipant[]=Bar&version[]=4.5.6"
query: "q[][pacticipant]=Foo&q[][version]=1.2.3&q[][pacticipant]=Bar&q[][version]=4.5.6"
).
will_respond_with(
status: 200,
Expand All @@ -42,7 +42,7 @@ module PactBroker::Client
with(
method: :get,
path: "/matrix",
query: "pacticipant[]=Foo+Thing&version[]=1.2.3&pacticipant[]=Bar&version[]=4.5.6"
query: "q[][pacticipant]=Foo%20Thing&q[][version]=1.2.3&q[][pacticipant]=Bar&q[][version]=4.5.6"
).
will_respond_with(
status: 200,
Expand Down Expand Up @@ -87,7 +87,7 @@ module PactBroker::Client
with(
method: :get,
path: "/matrix",
query: "pacticipant[]=Foo&version[]=1.2.3&pacticipant[]=Bar&version[]=9.9.9"
query: "q[][pacticipant]=Foo&q[][version]=1.2.3&q[][pacticipant]=Bar&q[][version]=9.9.9"
).
will_respond_with(
status: 400,
Expand All @@ -114,7 +114,7 @@ module PactBroker::Client
with(
method: :get,
path: "/matrix",
query: "pacticipant[]=Foo&version[]=1.2.3&pacticipant[]=Bar&version[]=9.9.9"
query: "q[][pacticipant]=Foo&q[][version]=1.2.3&q[][pacticipant]=Bar&q[][version]=9.9.9"
).
will_respond_with(
status: 400,
Expand Down

0 comments on commit 314e2e2

Please sign in to comment.