-
-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: in the webhook body for contract_published and contract_content…
…_changed, use the latest verification from the main branch if present
- Loading branch information
Showing
10 changed files
with
138 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
RSpec.describe "triggering a webhook for a pact publication" do | ||
before do | ||
td.create_global_webhook(event_names: ["contract_published"], body: { "provider_version" => "${pactbroker.providerVersionNumber}"}) | ||
end | ||
|
||
let(:pact_content) { td.random_json_content("Foo", "Bar") } | ||
|
||
let!(:request) do | ||
stub_request(:post, /http/).with(body: expected_webhook_body).to_return(:status => 200) | ||
end | ||
|
||
let(:database_connector) { ->(&block) { block.call } } | ||
|
||
subject { put("/pacts/provider/Bar/consumer/Foo/version/2", pact_content, { "CONTENT_TYPE" => "application/json", "pactbroker.database_connector" => database_connector}) } | ||
|
||
context "when there is a verification from the main branch of the provider" do | ||
before do | ||
td.create_consumer("Foo") | ||
.create_provider("Bar", main_branch: "main") | ||
.create_consumer_version("1") | ||
.create_pact(json_content: pact_content) | ||
.create_verification(provider_version: "1", branch: "main") | ||
.create_verification(provider_version: "2", branch: "feat/x", number: 2) | ||
end | ||
|
||
let(:expected_webhook_body) { { provider_version: "1"}.to_json } | ||
|
||
it "uses that in the webhook" do | ||
subject | ||
expect(request).to have_been_made | ||
end | ||
end | ||
|
||
context "when there is not a verification from the main branch of the provider" do | ||
before do | ||
td.create_consumer("Foo") | ||
.create_provider("Bar", main_branch: "main") | ||
.create_consumer_version("1") | ||
.create_pact(json_content: pact_content) | ||
.create_verification(provider_version: "1", branch: "feat/y") | ||
.create_verification(provider_version: "2", branch: "feat/x", number: 2) | ||
end | ||
|
||
let(:expected_webhook_body) { { provider_version: "2"}.to_json } | ||
|
||
it "uses the latest verification in the webhook" do | ||
subject | ||
expect(request).to have_been_made | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters