Skip to content

Commit

Permalink
test: test can-i-merge exits with failure if one app has failing result
Browse files Browse the repository at this point in the history
  • Loading branch information
YOU54F committed Oct 23, 2024
1 parent 12ee63f commit f77bfae
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
11 changes: 11 additions & 0 deletions spec/integration/can_i_merge_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ module CLI
invoke_can_i_merge
end

it "exits with failure if one pacticipant has a failing result" do
stub_request(:get, "http://pact-broker/matrix?latest=true&latestby=cvp&mainBranch=true&q%5B%5D%5Bpacticipant%5D=Bar&q%5B%5D%5Bversion%5D=5").
with(
headers: {
'Accept'=>'application/hal+json',
}).
to_return(status: 200, body: File.read("spec/support/matrix_with_failure.json"), headers: { "Content-Type" => "application/hal+json" })
stub_const("ARGV", %w[--pacticipant Bar --version 5])
expect($stdout).to receive(:puts).with(/Computer says no.*(success).*(failure)/m)
expect { invoke_can_i_merge }.to raise_error(SystemExit)
end

it "ignores pacticipant if --ignore flag is provided" do
stub_request(:get, "http://pact-broker/matrix?latest=true&latestby=cvp&mainBranch=true&q%5B%5D%5Bpacticipant%5D=Bar&q%5B%5D%5Bversion%5D=5&ignore%5B%5D%5Bpacticipant%5D=Foo").
Expand Down
61 changes: 61 additions & 0 deletions spec/support/matrix_with_failure.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"summary": {
"deployable": false,
"ignored": 0,
"unknown": 0
},
"matrix": [
{
"consumer": {
"name": "Baz",
"version": {
"number": "4"
}
},
"provider": {
"name": "Bar",
"version": {
"number": "5"
}
},
"verificationResult": {
"verifiedAt": "2017-10-10T12:49:04+11:00",
"success": true,
"_links": {
"self": {
"href": "http://result"
}
}
},
"pact": {
"createdAt": "2017-10-10T12:49:04+11:00"
}
},
{
"consumer": {
"name": "Foo",
"version": {
"number": "4"
}
},
"provider": {
"name": "Bar",
"version": {
"number": "5"
}
},
"verificationResult": {
"verifiedAt": "2017-10-10T12:49:04+11:00",
"success": false,
"_links": {
"self": {
"href": "http://result"
}
}
},
"pact": {
"createdAt": "2017-10-10T12:49:04+11:00"
}
}
]
}

0 comments on commit f77bfae

Please sign in to comment.