Skip to content

Commit

Permalink
feat(wip pacts): if a pact was successfully verified because it was i…
Browse files Browse the repository at this point in the history
…ncluded as a WIP pact, keep it as WIP
  • Loading branch information
bethesque committed Oct 5, 2020
1 parent 34f9859 commit 16cae55
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/pact_broker/pacts/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ def find_successfully_verified_head_pacts_by_provider_tag(provider_id, provider_
verifications_join = {
pact_version_id: :pact_version_id,
Sequel[:verifications][:success] => true,
Sequel[:verifications][:wip] => false,
Sequel[:verifications][:provider_id] => provider_id
}
tags_join = {
Expand Down
2 changes: 1 addition & 1 deletion lib/pact_broker/test/test_data_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def create_verification parameters = {}
parameters.delete(:comment)
tag_names = [parameters.delete(:tag_names), parameters.delete(:tag_name)].flatten.compact
provider_version_number = parameters[:provider_version] || '4.5.6'
default_parameters = {success: true, number: 1, test_results: {some: 'results'}}
default_parameters = { success: true, number: 1, test_results: {some: 'results'}, wip: false }
default_parameters[:execution_date] = @now if @now
parameters = default_parameters.merge(parameters)
parameters.delete(:provider_version)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
module PactBroker
module Pacts
describe Repository do
let(:td) { TestDataBuilder.new }

describe "find_wip_pact_versions_for_provider" do
let(:provider_tags) { %w[dev] }
let(:options) { { include_wip_pacts_since: include_wip_pacts_since } }
Expand Down Expand Up @@ -73,6 +71,28 @@ module Pacts
end
end

context "when the latest pact for a tag has been successfully verified by the given provider tag but it was a WIP verification" do
before do
td.create_provider("bar")
.create_provider_version("333")
.create_provider_version_tag("dev")
.add_day
.create_pact_with_hierarchy("foo", "1", "bar")
.comment("above not included because it's not the latest dev")
.create_consumer_version("2")
.create_consumer_version_tag("feat-1")
.create_pact
.create_verification(wip: true, success: true, provider_version: "3", tag_names: %w[dev])
end

let(:provider_tags) { %w[dev] }

it "it is included" do
expect(subject[0].consumer_name).to eq "foo"
expect(subject[0].consumer_version_number).to eq "2"
end
end

context "when the latest pact for a tag has been successfully verified by one of the given provider tags, but not the other" do
before do
td.create_provider("bar")
Expand Down Expand Up @@ -145,6 +165,8 @@ module Pacts
end
end



context "when the latest pact for a tag has not been verified" do
before do
td.create_provider("bar")
Expand Down

0 comments on commit 16cae55

Please sign in to comment.