pact_broker 2.68.1 → 2.69.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release_gem.yml +7 -1
- data/CHANGELOG.md +17 -0
- data/Gemfile +2 -1
- data/db/ddl_statements/latest_verification_ids_for_consumer_and_provider.rb +25 -0
- data/db/migrations/20180524_create_latest_verifications_for_consumer_and_provider.rb +4 -11
- data/db/migrations/20180614_update_latest_verification_ids_for_consumer_and_provider.rb +6 -18
- data/db/migrations/20201026_update_latest_verification_ids_for_consumer_and_provider.rb +14 -0
- data/lib/pact/doc/interaction_view_model.rb +12 -0
- data/lib/pact/doc/markdown/interaction.erb +3 -3
- data/lib/pact/doc/markdown/interaction_renderer.rb +2 -1
- data/lib/pact_broker/api/decorators/pact_decorator.rb +8 -0
- data/lib/pact_broker/api/resources/pact_content_diff.rb +1 -1
- data/lib/pact_broker/api/resources/webhooks.rb +1 -1
- data/lib/pact_broker/db/clean.rb +30 -10
- data/lib/pact_broker/matrix/unresolved_selector.rb +4 -0
- data/lib/pact_broker/pacts/latest_pact_publications.rb +15 -0
- data/lib/pact_broker/pacts/metadata.rb +5 -1
- data/lib/pact_broker/pacts/verifiable_pact_messages.rb +1 -1
- data/lib/pact_broker/tasks/clean_task.rb +17 -3
- data/lib/pact_broker/version.rb +1 -1
- data/pact_broker.gemspec +1 -1
- data/spec/lib/pact/doc/interaction_view_model_spec.rb +46 -0
- data/spec/lib/pact/doc/markdown/consumer_contract_renderer_spec.rb +11 -0
- data/spec/lib/pact_broker/api/pact_broker_urls_spec.rb +1 -1
- data/spec/lib/pact_broker/db/clean_spec.rb +4 -8
- data/spec/support/markdown_pact_v3.json +44 -0
- metadata +10 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03c656c61487fd81baf9eb94f73fa12ab27bdf5cea1bd2d670af63199123b6ef
|
4
|
+
data.tar.gz: '04022874b3eeb6681e79163431ce63c8d6760741dc7ec8db30cc87b8f9257a94'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce0f9fb3186ab25c419b61665245977abfbaa8d245437699c44de54783bde86d8281b950172532d02a31f6aa33f36046dde7a0636075fabe75f3f074c33016c2
|
7
|
+
data.tar.gz: f6b8baa8a66b80b50df9223086f8e67dd9233106897b15f5cfa16328e954805de786d4fbe672f3cee5ba831001edd78f5c0a977dfc5d767d4c79aa46a61b1010
|
@@ -19,11 +19,17 @@ jobs:
|
|
19
19
|
# checkInterval: 15
|
20
20
|
# env:
|
21
21
|
# GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
22
|
-
-
|
22
|
+
- id: release-gem
|
23
|
+
uses: pact-foundation/release-gem@v0.0.11
|
23
24
|
env:
|
24
25
|
GEM_HOST_API_KEY: '${{ secrets.RUBYGEMS_API_KEY }}'
|
25
26
|
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
|
26
27
|
INCREMENT: '${{ github.event.client_payload.increment }}'
|
28
|
+
outputs:
|
29
|
+
gem_name: "${{ steps.release-gem.outputs.gem_name }}"
|
30
|
+
version: "${{ steps.release-gem.outputs.version }}"
|
31
|
+
increment: "${{ steps.release-gem.outputs.increment }}"
|
32
|
+
|
27
33
|
notify-gem-released:
|
28
34
|
needs: release
|
29
35
|
strategy:
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
<a name="v2.69.0"></a>
|
2
|
+
### v2.69.0 (2020-11-24)
|
3
|
+
|
4
|
+
#### Features
|
5
|
+
|
6
|
+
* **wip**
|
7
|
+
* keep pacts as WIP when verified via the pactUrl passed though the webhook template parameters - experimental. ([a9b3fef0](/../../commit/a9b3fef0))
|
8
|
+
|
9
|
+
* add link to the pact content version ([8eefba5f](/../../commit/8eefba5f))
|
10
|
+
* display V3 provider states in HTML (#357) ([8e06a7f2](/../../commit/8e06a7f2))
|
11
|
+
* optimise query for determining latest verification for consumer and provider ([7889b051](/../../commit/7889b051))
|
12
|
+
|
13
|
+
#### Bug Fixes
|
14
|
+
|
15
|
+
* return a 404 when the base pact for a pact diff doesn't exist ([74d3644d](/../../commit/74d3644d))
|
16
|
+
* Add consumer name to inclusion reason log (#358) ([82901891](/../../commit/82901891))
|
17
|
+
|
1
18
|
<a name="v2.68.1"></a>
|
2
19
|
### v2.68.1 (2020-10-24)
|
3
20
|
|
data/Gemfile
CHANGED
@@ -18,12 +18,13 @@ group :test do
|
|
18
18
|
gem 'rspec-pact-matchers', '~>0.1'
|
19
19
|
gem 'bundler-audit', '~>0.4'
|
20
20
|
gem 'fakefs', '~>0.4'
|
21
|
-
gem 'webmock', '~>
|
21
|
+
gem 'webmock', '~>3.9'
|
22
22
|
gem 'rspec', '~>3.0'
|
23
23
|
gem 'rspec-its', '~>1.2'
|
24
24
|
gem 'database_cleaner', '~>1.8', '>= 1.8.1'
|
25
25
|
gem 'timecop', '~> 0.9'
|
26
26
|
gem 'faraday', '~>0.15'
|
27
|
+
gem 'faraday_middleware', '~> 0.14'
|
27
28
|
gem 'docker-api', '~>1.34'
|
28
29
|
gem 'approvals', '>=0.0.1', '<1.0.0'
|
29
30
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
LATEST_VERIFICATION_IDS_FOR_CONSUMER_AND_PROVIDER_V1 = "select
|
2
|
+
pv.pacticipant_id as provider_id,
|
3
|
+
lpp.consumer_id,
|
4
|
+
max(v.id) as latest_verification_id
|
5
|
+
from verifications v
|
6
|
+
join latest_pact_publications_by_consumer_versions lpp
|
7
|
+
on v.pact_version_id = lpp.pact_version_id
|
8
|
+
join versions pv
|
9
|
+
on v.provider_version_id = pv.id
|
10
|
+
group by pv.pacticipant_id, lpp.consumer_id"
|
11
|
+
|
12
|
+
LATEST_VERIFICATION_IDS_FOR_CONSUMER_AND_PROVIDER_V2 = "select
|
13
|
+
provider_id,
|
14
|
+
consumer_id,
|
15
|
+
max(id) as latest_verification_id
|
16
|
+
from verifications v
|
17
|
+
group by provider_id, consumer_id"
|
18
|
+
|
19
|
+
|
20
|
+
LATEST_VERIFICATION_IDS_FOR_CONSUMER_AND_PROVIDER_V3 = "select
|
21
|
+
provider_id,
|
22
|
+
consumer_id,
|
23
|
+
max(verification_id) as latest_verification_id
|
24
|
+
from latest_verification_id_for_pact_version_and_provider_version v
|
25
|
+
group by provider_id, consumer_id"
|
@@ -1,17 +1,10 @@
|
|
1
|
+
require_relative '../ddl_statements/latest_verification_ids_for_consumer_and_provider'
|
2
|
+
|
1
3
|
Sequel.migration do
|
2
4
|
up do
|
3
|
-
# The latest verification id for each consumer
|
5
|
+
# The latest verification id for each consumer/provider
|
4
6
|
create_view(:latest_verification_ids_for_consumer_and_provider,
|
5
|
-
|
6
|
-
pv.pacticipant_id as provider_id,
|
7
|
-
lpp.consumer_id,
|
8
|
-
max(v.id) as latest_verification_id
|
9
|
-
from verifications v
|
10
|
-
join latest_pact_publications_by_consumer_versions lpp
|
11
|
-
on v.pact_version_id = lpp.pact_version_id
|
12
|
-
join versions pv
|
13
|
-
on v.provider_version_id = pv.id
|
14
|
-
group by pv.pacticipant_id, lpp.consumer_id")
|
7
|
+
LATEST_VERIFICATION_IDS_FOR_CONSUMER_AND_PROVIDER_V1)
|
15
8
|
|
16
9
|
# The most recent verification for each consumer/consumer version tag/provider
|
17
10
|
latest_verifications = from(:verifications)
|
@@ -1,27 +1,15 @@
|
|
1
|
+
require_relative '../ddl_statements/latest_verification_ids_for_consumer_and_provider'
|
2
|
+
|
1
3
|
Sequel.migration do
|
2
4
|
up do
|
3
|
-
# The latest verification id for each consumer
|
5
|
+
# The latest verification id for each consumer/provider
|
4
6
|
create_or_replace_view(:latest_verification_ids_for_consumer_and_provider,
|
5
|
-
|
6
|
-
provider_id,
|
7
|
-
consumer_id,
|
8
|
-
max(id) as latest_verification_id
|
9
|
-
from verifications v
|
10
|
-
group by provider_id, consumer_id")
|
7
|
+
LATEST_VERIFICATION_IDS_FOR_CONSUMER_AND_PROVIDER_V2)
|
11
8
|
end
|
12
9
|
|
13
10
|
down do
|
14
|
-
# The latest verification id for each consumer
|
11
|
+
# The latest verification id for each consumer/provider
|
15
12
|
create_or_replace_view(:latest_verification_ids_for_consumer_and_provider,
|
16
|
-
|
17
|
-
pv.pacticipant_id as provider_id,
|
18
|
-
lpp.consumer_id,
|
19
|
-
max(v.id) as latest_verification_id
|
20
|
-
from verifications v
|
21
|
-
join latest_pact_publications_by_consumer_versions lpp
|
22
|
-
on v.pact_version_id = lpp.pact_version_id
|
23
|
-
join versions pv
|
24
|
-
on v.provider_version_id = pv.id
|
25
|
-
group by pv.pacticipant_id, lpp.consumer_id")
|
13
|
+
LATEST_VERIFICATION_IDS_FOR_CONSUMER_AND_PROVIDER_V1)
|
26
14
|
end
|
27
15
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative 'migration_helper'
|
2
|
+
require_relative '../ddl_statements/latest_verification_ids_for_consumer_and_provider'
|
3
|
+
|
4
|
+
Sequel.migration do
|
5
|
+
up do
|
6
|
+
create_or_replace_view(:latest_verification_ids_for_consumer_and_provider,
|
7
|
+
LATEST_VERIFICATION_IDS_FOR_CONSUMER_AND_PROVIDER_V3)
|
8
|
+
end
|
9
|
+
|
10
|
+
down do
|
11
|
+
create_or_replace_view(:latest_verification_ids_for_consumer_and_provider,
|
12
|
+
LATEST_VERIFICATION_IDS_FOR_CONSUMER_AND_PROVIDER_V2)
|
13
|
+
end
|
14
|
+
end
|
@@ -8,6 +8,8 @@ module Pact
|
|
8
8
|
|
9
9
|
include Pact::ActiveSupportSupport
|
10
10
|
|
11
|
+
MARKDOWN_BOLD_CHARACTERS = '**'
|
12
|
+
|
11
13
|
def initialize interaction, consumer_contract
|
12
14
|
@interaction = interaction
|
13
15
|
@consumer_contract = consumer_contract
|
@@ -52,6 +54,16 @@ module Pact
|
|
52
54
|
markdown_escape apply_capitals(@interaction.provider_state.strip, start_of_sentence)
|
53
55
|
end
|
54
56
|
|
57
|
+
def formatted_provider_states mark_bold: false
|
58
|
+
bold_marker = mark_bold ? MARKDOWN_BOLD_CHARACTERS : ''
|
59
|
+
|
60
|
+
(@interaction.provider_states || []).map do |ps|
|
61
|
+
"#{bold_marker}" \
|
62
|
+
"#{markdown_escape(apply_capitals(ps.name.strip, false))}" \
|
63
|
+
"#{bold_marker}"
|
64
|
+
end.join(' and ')
|
65
|
+
end
|
66
|
+
|
55
67
|
def description start_of_sentence = false
|
56
68
|
return '' unless @interaction.description
|
57
69
|
markdown_escape apply_capitals(@interaction.description.strip, start_of_sentence)
|
@@ -1,6 +1,6 @@
|
|
1
|
-
<a name="<%= interaction.id %>"></a
|
2
|
-
<%= if
|
3
|
-
"Given
|
1
|
+
<a name="<%= interaction.id %>"></a><% formatted_provider_states = h(interaction.formatted_provider_states mark_bold: true) %>
|
2
|
+
<%= if !formatted_provider_states.empty?
|
3
|
+
"Given #{formatted_provider_states}, upon receiving"
|
4
4
|
else
|
5
5
|
"Upon receiving"
|
6
6
|
end
|
@@ -13,7 +13,8 @@ module Pact
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def render_summary
|
16
|
-
|
16
|
+
formatted_provider_states = h(interaction.formatted_provider_states)
|
17
|
+
suffix = formatted_provider_states.empty? ? "" : " given #{formatted_provider_states}"
|
17
18
|
"* [#{h(interaction.description(true))}](##{interaction.id})#{suffix}\n\n"
|
18
19
|
end
|
19
20
|
|
@@ -50,6 +50,14 @@ module PactBroker
|
|
50
50
|
}
|
51
51
|
end
|
52
52
|
|
53
|
+
link :'pb:pact-version' do | options |
|
54
|
+
{
|
55
|
+
title: "Pact content version permalink",
|
56
|
+
name: represented.pact_version_sha,
|
57
|
+
href: pact_version_url(represented, options.fetch(:base_url))
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
53
61
|
link :'pb:latest-pact-version' do | options |
|
54
62
|
{
|
55
63
|
title: "Latest version of this pact",
|
data/lib/pact_broker/db/clean.rb
CHANGED
@@ -25,17 +25,17 @@ module PactBroker
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def keep
|
28
|
-
options[:keep] || [PactBroker::Matrix::UnresolvedSelector.new(tag: true, latest: true)]
|
28
|
+
options[:keep] || [PactBroker::Matrix::UnresolvedSelector.new(tag: true, latest: true), PactBroker::Matrix::UnresolvedSelector.new(latest: true)]
|
29
29
|
end
|
30
30
|
|
31
|
-
def resolve_ids(query)
|
31
|
+
def resolve_ids(query, column_name = :id)
|
32
32
|
# query
|
33
|
-
Unionable.new(query.collect { |h| h[
|
33
|
+
Unionable.new(query.collect { |h| h[column_name] })
|
34
34
|
end
|
35
35
|
|
36
36
|
def pact_publication_ids_to_keep
|
37
37
|
@pact_publication_ids_to_keep ||= pact_publication_ids_to_keep_for_version_ids_to_keep
|
38
|
-
.union(
|
38
|
+
.union(latest_pact_publication_ids_to_keep)
|
39
39
|
.union(latest_tagged_pact_publications_ids_to_keep)
|
40
40
|
end
|
41
41
|
|
@@ -43,16 +43,17 @@ module PactBroker
|
|
43
43
|
@pact_publication_ids_to_keep_for_version_ids_to_keep ||= resolve_ids(db[:pact_publications].select(:id).where(consumer_version_id: version_ids_to_keep))
|
44
44
|
end
|
45
45
|
|
46
|
-
def pact_publications_to_keep_for_verification_ids_to_keep
|
47
|
-
@pact_publications_to_keep_for_verification_ids_to_keep ||= resolve_ids(db[:pact_publications].select(:id).where(pact_version_id: db[:verifications].select(:pact_version_id).where(id: verification_ids_to_keep_for_version_ids_to_keep)))
|
48
|
-
end
|
49
|
-
|
50
46
|
def latest_tagged_pact_publications_ids_to_keep
|
51
47
|
@latest_tagged_pact_publications_ids_to_keep ||= resolve_ids(keep.select(&:tag).select(&:latest).collect do | selector |
|
52
48
|
PactBroker::Pacts::LatestTaggedPactPublications.select(:id).for_selector(selector)
|
53
49
|
end.reduce(&:union))
|
54
50
|
end
|
55
51
|
|
52
|
+
|
53
|
+
def latest_pact_publication_ids_to_keep
|
54
|
+
@latest_pact_publication_ids_to_keep ||= resolve_ids(db[:latest_pact_publications].select(:id))
|
55
|
+
end
|
56
|
+
|
56
57
|
def pact_publication_ids_to_delete
|
57
58
|
@pact_publication_ids_to_delete ||= resolve_ids(db[:pact_publications].select(:id).where(id: pact_publication_ids_to_keep).invert)
|
58
59
|
end
|
@@ -62,12 +63,31 @@ module PactBroker
|
|
62
63
|
@verification_ids_to_keep_for_version_ids_to_keep ||= resolve_ids(db[:verifications].select(:id).where(provider_version_id: version_ids_to_keep))
|
63
64
|
end
|
64
65
|
|
66
|
+
def verification_ids_to_keep_because_latest_verification_for_latest_pact
|
67
|
+
@verification_ids_to_keep_because_latest_verification ||= resolve_ids(
|
68
|
+
db[:latest_verification_ids_for_pact_versions]
|
69
|
+
.select(:latest_verification_id)
|
70
|
+
.where(pact_version_id:
|
71
|
+
db[:latest_pact_publications].select(:pact_version_id)
|
72
|
+
),
|
73
|
+
:latest_verification_id
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
65
77
|
def verification_ids_to_keep_for_pact_publication_ids_to_keep
|
66
|
-
@verification_ids_to_keep_for_pact_publication_ids_to_keep ||= resolve_ids(
|
78
|
+
@verification_ids_to_keep_for_pact_publication_ids_to_keep ||= resolve_ids(
|
79
|
+
db[:latest_verification_id_for_pact_version_and_provider_version]
|
80
|
+
.select(:verification_id)
|
81
|
+
.where(pact_version_id:
|
82
|
+
db[:pact_publications]
|
83
|
+
.select(:pact_version_id)
|
84
|
+
.where(id: pact_publication_ids_to_keep_for_version_ids_to_keep)
|
85
|
+
)
|
86
|
+
)
|
67
87
|
end
|
68
88
|
|
69
89
|
def verification_ids_to_keep
|
70
|
-
@verification_ids_to_keep ||= verification_ids_to_keep_for_version_ids_to_keep.union(
|
90
|
+
@verification_ids_to_keep ||= verification_ids_to_keep_for_version_ids_to_keep.union(verification_ids_to_keep_because_latest_verification_for_latest_pact)
|
71
91
|
end
|
72
92
|
|
73
93
|
def verification_ids_to_delete
|
@@ -8,6 +8,21 @@ module PactBroker
|
|
8
8
|
class LatestPactPublications < LatestPactPublicationsByConsumerVersion
|
9
9
|
set_dataset(:latest_pact_publications)
|
10
10
|
|
11
|
+
# def dataset_module
|
12
|
+
# def where_age_less_than(days)
|
13
|
+
# start_date = Date.today - days
|
14
|
+
# where{ latest_pact_publications[:created_at] >= start_date }
|
15
|
+
# end
|
16
|
+
|
17
|
+
# def for_selector(selector)
|
18
|
+
# query = self
|
19
|
+
# query = query.where(consumer_name: selector.pacticipant_name) if selector.pacticipant_name
|
20
|
+
# query = query.where(tag_name: selector.tag) if selector.tag && selector.tag.is_a?(String)
|
21
|
+
# query = query.where_age_less_than(selector.max_age) if selector.max_age
|
22
|
+
# query
|
23
|
+
# end
|
24
|
+
# end
|
25
|
+
|
11
26
|
# This pact may well be the latest for certain tags, but in this query
|
12
27
|
# we don't know what they are
|
13
28
|
def to_domain
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'pact_broker/feature_toggle'
|
2
|
+
|
1
3
|
module PactBroker
|
2
4
|
module Pacts
|
3
5
|
module Metadata
|
@@ -27,10 +29,12 @@ module PactBroker
|
|
27
29
|
# parameters. This is part of ensuring that verification results webhooks
|
28
30
|
# go back to the correct consumer version number (eg for git statuses)
|
29
31
|
def build_metadata_for_webhook_triggered_by_pact_publication(pact)
|
30
|
-
{
|
32
|
+
metadata = {
|
31
33
|
consumer_version_number: pact.consumer_version_number,
|
32
34
|
consumer_version_tags: pact.consumer_version_tag_names
|
33
35
|
}
|
36
|
+
metadata[:wip] = "true" if PactBroker.feature_enabled?(:experimental_webhook_wip)
|
37
|
+
metadata
|
34
38
|
end
|
35
39
|
end
|
36
40
|
end
|
@@ -29,7 +29,7 @@ module PactBroker
|
|
29
29
|
version_text = head_consumer_tags.size == 1 ? "version" : "versions"
|
30
30
|
if wip?
|
31
31
|
# WIP pacts will always have tags, because it is part of the definition of being a WIP pact
|
32
|
-
"The pact at #{pact_version_url} is being verified because it is a 'work in progress' pact (ie. it is the pact for the latest #{version_text} of
|
32
|
+
"The pact at #{pact_version_url} is being verified because it is a 'work in progress' pact (ie. it is the pact for the latest #{version_text} of #{consumer_name} tagged with #{joined_head_consumer_tags} and is still in pending state). #{READ_MORE_WIP}"
|
33
33
|
else
|
34
34
|
criteria_or_criterion = selectors.size > 1 ? "criteria" : "criterion"
|
35
35
|
"The pact at #{pact_version_url} is being verified because it matches the following configured selection #{criteria_or_criterion}: #{selector_descriptions}#{same_content_note}"
|
@@ -3,6 +3,7 @@ module PactBroker
|
|
3
3
|
class CleanTask < ::Rake::TaskLib
|
4
4
|
|
5
5
|
attr_accessor :database_connection
|
6
|
+
attr_accessor :keep
|
6
7
|
|
7
8
|
def initialize &block
|
8
9
|
rake_task &block
|
@@ -11,11 +12,24 @@ module PactBroker
|
|
11
12
|
def rake_task &block
|
12
13
|
namespace :pact_broker do
|
13
14
|
namespace :db do
|
14
|
-
desc "Clean
|
15
|
+
desc "Clean unnecessary pacts and verifications from database"
|
15
16
|
task :clean do | t, args |
|
16
|
-
|
17
|
+
|
17
18
|
instance_eval(&block)
|
18
|
-
|
19
|
+
|
20
|
+
require 'pact_broker/db/clean'
|
21
|
+
require 'pact_broker/matrix/unresolved_selector'
|
22
|
+
require 'yaml'
|
23
|
+
|
24
|
+
keep_selectors = nil
|
25
|
+
if keep
|
26
|
+
keep_selectors = [*keep].collect do | hash |
|
27
|
+
PactBroker::Matrix::UnresolvedSelector.new(hash)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
# TODO time it
|
31
|
+
results = PactBroker::DB::Clean.call(database_connection, keep: keep_selectors)
|
32
|
+
puts results.to_yaml
|
19
33
|
end
|
20
34
|
end
|
21
35
|
end
|
data/lib/pact_broker/version.rb
CHANGED
data/pact_broker.gemspec
CHANGED
@@ -53,7 +53,7 @@ Gem::Specification.new do |gem|
|
|
53
53
|
gem.add_runtime_dependency 'semver2', '~> 3.4.2'
|
54
54
|
gem.add_runtime_dependency 'rack', '>= 2.2.3', '~> 2.2'
|
55
55
|
gem.add_runtime_dependency 'redcarpet', '>=3.3.2', '~>3.3'
|
56
|
-
gem.add_runtime_dependency 'pact-support', '
|
56
|
+
gem.add_runtime_dependency 'pact-support', '1.15.0'
|
57
57
|
gem.add_runtime_dependency 'padrino-core', '>= 0.14.3', '~> 0.14'
|
58
58
|
gem.add_runtime_dependency 'sinatra', '>= 2.0.8.1', '< 3.0'
|
59
59
|
gem.add_runtime_dependency 'haml', '~>5.0'
|
@@ -181,6 +181,52 @@ module Pact
|
|
181
181
|
end
|
182
182
|
end
|
183
183
|
end
|
184
|
+
|
185
|
+
describe "formatted_provider_states" do
|
186
|
+
let(:consumer_contract) { Pact::ConsumerContract.from_uri './spec/support/markdown_pact.json' }
|
187
|
+
let(:interaction) { consumer_contract.interactions.first }
|
188
|
+
|
189
|
+
context "when no provider state" do
|
190
|
+
let(:interaction) { consumer_contract.interactions.last }
|
191
|
+
|
192
|
+
it "returns an empty string" do
|
193
|
+
expect(subject.formatted_provider_states).to eq ""
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
context "when marking provider states in bold" do
|
198
|
+
it "formats the provider state in bold" do
|
199
|
+
expect(subject.formatted_provider_states mark_bold: true).to eq "**alligators exist**"
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
context "when not marking provider states in bold" do
|
204
|
+
it "formats the provider state without bold" do
|
205
|
+
expect(subject.formatted_provider_states).to eq "alligators exist"
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
context "when using v3 specification" do
|
210
|
+
let(:consumer_contract) { Pact::ConsumerContract.from_uri './spec/support/markdown_pact_v3.json' }
|
211
|
+
let(:interaction) { consumer_contract.interactions.first }
|
212
|
+
|
213
|
+
context "when marking provider states in bold" do
|
214
|
+
it "formats the provider states in bold" do
|
215
|
+
expected_result = '**alligators exist** and **the city of Tel Aviv has a zoo** ' \
|
216
|
+
'and **the zoo keeps record of its alligator population**'
|
217
|
+
expect(subject.formatted_provider_states mark_bold: true).to eq expected_result
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
context "when not marking provider states in bold" do
|
222
|
+
it "formats the provider states without bold" do
|
223
|
+
expected_result = 'alligators exist and the city of Tel Aviv has a zoo ' \
|
224
|
+
'and the zoo keeps record of its alligator population'
|
225
|
+
expect(subject.formatted_provider_states).to eq expected_result
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
184
230
|
end
|
185
231
|
end
|
186
232
|
end
|
@@ -12,6 +12,17 @@ module Pact
|
|
12
12
|
subject { ConsumerContractRenderer.new(consumer_contract) }
|
13
13
|
|
14
14
|
describe "#call" do
|
15
|
+
context "when using V3 specification" do
|
16
|
+
context "when an interaction has multiple provider states" do
|
17
|
+
let(:consumer_contract) { Pact::ConsumerContract.from_uri './spec/support/markdown_pact_v3.json' }
|
18
|
+
|
19
|
+
it "displays all provider states in the interaction title" do
|
20
|
+
expect(subject.call).to include 'Given **alligators exist** and **the city of Tel Aviv has a zoo** ' \
|
21
|
+
'and **the zoo keeps record of its alligator population**, upon receiving'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
15
26
|
context "with markdown characters in the pacticipant names" do
|
16
27
|
let(:consumer_contract) { Pact::ConsumerContract.from_uri './spec/support/markdown_pact_with_markdown_chars_in_names.json' }
|
17
28
|
|
@@ -107,7 +107,7 @@ module PactBroker
|
|
107
107
|
|
108
108
|
describe "webhook metadata" do
|
109
109
|
let(:expected_metadata) do
|
110
|
-
{ consumer_version_number: "123/456", consumer_version_tags: %w[dev] }
|
110
|
+
{ consumer_version_number: "123/456", consumer_version_tags: %w[dev], wip: "true" }
|
111
111
|
end
|
112
112
|
|
113
113
|
it "builds the webhook metadata" do
|
@@ -33,6 +33,8 @@ module PactBroker
|
|
33
33
|
.create_pact
|
34
34
|
.create_consumer_version("6", tag_names: %w{foo})
|
35
35
|
.create_pact
|
36
|
+
.create_consumer_version("7")
|
37
|
+
.create_pact
|
36
38
|
end
|
37
39
|
|
38
40
|
let(:options) { { keep: [all_prod_selector, latest_dev_selector] } }
|
@@ -43,12 +45,14 @@ module PactBroker
|
|
43
45
|
expect(PactBroker::Domain::Version.where(number: "4").count).to be 1
|
44
46
|
expect(PactBroker::Domain::Version.where(number: "5").count).to be 1
|
45
47
|
expect(PactBroker::Domain::Version.where(number: "6").count).to be 1
|
48
|
+
expect(PactBroker::Domain::Version.where(number: "7").count).to be 1
|
46
49
|
subject
|
47
50
|
expect(PactBroker::Domain::Version.where(number: "1").count).to be 1
|
48
51
|
expect(PactBroker::Domain::Version.where(number: "3").count).to be 1
|
49
52
|
expect(PactBroker::Domain::Version.where(number: "4").count).to be 0
|
50
53
|
expect(PactBroker::Domain::Version.where(number: "5").count).to be 1
|
51
54
|
expect(PactBroker::Domain::Version.where(number: "6").count).to be 0
|
55
|
+
expect(PactBroker::Domain::Version.where(number: "7").count).to be 1 # doesn't delete overall latest
|
52
56
|
end
|
53
57
|
end
|
54
58
|
|
@@ -97,12 +101,6 @@ module PactBroker
|
|
97
101
|
}.by(-1)
|
98
102
|
end
|
99
103
|
|
100
|
-
it "does not delete the pact publication that belongs to the latest verification" do
|
101
|
-
expect{ subject }.to_not change {
|
102
|
-
PactBroker::Pacts::PactPublication.where(consumer_version: PactBroker::Domain::Version.where_pacticipant_name("Foo").where(number: "2")).count
|
103
|
-
}
|
104
|
-
end
|
105
|
-
|
106
104
|
it "deletes the pact publication that does not belongs to the latest verification" do
|
107
105
|
expect{ subject }.to change {
|
108
106
|
PactBroker::Pacts::PactPublication.where(consumer_version: PactBroker::Domain::Version.where_pacticipant_name("Foo").where(number: "1")).count
|
@@ -110,8 +108,6 @@ module PactBroker
|
|
110
108
|
end
|
111
109
|
end
|
112
110
|
|
113
|
-
|
114
|
-
|
115
111
|
context "with orphan pact versions" do
|
116
112
|
before do
|
117
113
|
# Create a pact that will not be deleted
|
@@ -0,0 +1,44 @@
|
|
1
|
+
{
|
2
|
+
"provider": {
|
3
|
+
"name": "Some Provider"
|
4
|
+
},
|
5
|
+
"consumer": {
|
6
|
+
"name": "Some Consumer"
|
7
|
+
},
|
8
|
+
"interactions": [
|
9
|
+
{
|
10
|
+
"description": "a request to list all alligators in Tel Aviv",
|
11
|
+
"providerStates": [
|
12
|
+
{"name": "alligators exist", "params" : {}},
|
13
|
+
{"name": "the city of Tel Aviv has a zoo", "params" : {}},
|
14
|
+
{"name": "the zoo keeps record of its alligator population", "params" : {}}
|
15
|
+
],
|
16
|
+
"params": {},
|
17
|
+
"request": {
|
18
|
+
"method": "get",
|
19
|
+
"path": "/alligators"
|
20
|
+
},
|
21
|
+
"response": {
|
22
|
+
"headers" : {"Content-Type": "application/json"},
|
23
|
+
"status" : 200,
|
24
|
+
"body" : {
|
25
|
+
"alligators": [{
|
26
|
+
"name": "Bob",
|
27
|
+
"phoneNumber" : {
|
28
|
+
"json_class": "Pact::Term",
|
29
|
+
"data": {
|
30
|
+
"generate": "12345678",
|
31
|
+
"matcher": {"json_class":"Regexp","o":0,"s":"\\d+"}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}]
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}
|
38
|
+
],
|
39
|
+
"metadata": {
|
40
|
+
"pactSpecification": {
|
41
|
+
"version": "3.0.0"
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pact_broker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.69.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bethany Skurrie
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-
|
13
|
+
date: 2020-11-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: httparty
|
@@ -174,22 +174,16 @@ dependencies:
|
|
174
174
|
name: pact-support
|
175
175
|
requirement: !ruby/object:Gem::Requirement
|
176
176
|
requirements:
|
177
|
-
- -
|
178
|
-
- !ruby/object:Gem::Version
|
179
|
-
version: '1.14'
|
180
|
-
- - ">="
|
177
|
+
- - '='
|
181
178
|
- !ruby/object:Gem::Version
|
182
|
-
version: 1.
|
179
|
+
version: 1.15.0
|
183
180
|
type: :runtime
|
184
181
|
prerelease: false
|
185
182
|
version_requirements: !ruby/object:Gem::Requirement
|
186
183
|
requirements:
|
187
|
-
- -
|
188
|
-
- !ruby/object:Gem::Version
|
189
|
-
version: '1.14'
|
190
|
-
- - ">="
|
184
|
+
- - '='
|
191
185
|
- !ruby/object:Gem::Version
|
192
|
-
version: 1.
|
186
|
+
version: 1.15.0
|
193
187
|
- !ruby/object:Gem::Dependency
|
194
188
|
name: padrino-core
|
195
189
|
requirement: !ruby/object:Gem::Requirement
|
@@ -403,6 +397,7 @@ files:
|
|
403
397
|
- db/ddl_statements/latest_pact_publications_by_consumer_versions.rb
|
404
398
|
- db/ddl_statements/latest_tagged_pact_consumer_version_orders.rb
|
405
399
|
- db/ddl_statements/latest_triggered_webhooks.rb
|
400
|
+
- db/ddl_statements/latest_verification_ids_for_consumer_and_provider.rb
|
406
401
|
- db/ddl_statements/latest_verification_ids_for_consumer_version_tags.rb
|
407
402
|
- db/ddl_statements/latest_verification_ids_for_pact_versions.rb
|
408
403
|
- db/migrations/000001_create_pacticipant_table.rb
|
@@ -523,6 +518,7 @@ files:
|
|
523
518
|
- db/migrations/20201006_add_wip_to_verification.rb
|
524
519
|
- db/migrations/20201023_create_verification_number_sequence.rb
|
525
520
|
- db/migrations/20201024_create_version_order_sequence.rb
|
521
|
+
- db/migrations/20201026_update_latest_verification_ids_for_consumer_and_provider.rb
|
526
522
|
- db/migrations/migration_helper.rb
|
527
523
|
- db/test/backwards_compatibility/.rspec
|
528
524
|
- db/test/backwards_compatibility/Appraisals
|
@@ -1357,6 +1353,7 @@ files:
|
|
1357
1353
|
- spec/support/interaction_view_model_with_terms.json
|
1358
1354
|
- spec/support/logging.rb
|
1359
1355
|
- spec/support/markdown_pact.json
|
1356
|
+
- spec/support/markdown_pact_v3.json
|
1360
1357
|
- spec/support/markdown_pact_with_html.json
|
1361
1358
|
- spec/support/markdown_pact_with_markdown_chars_in_names.json
|
1362
1359
|
- spec/support/metadata_test_server.rb
|
@@ -1751,6 +1748,7 @@ test_files:
|
|
1751
1748
|
- spec/support/interaction_view_model_with_terms.json
|
1752
1749
|
- spec/support/logging.rb
|
1753
1750
|
- spec/support/markdown_pact.json
|
1751
|
+
- spec/support/markdown_pact_v3.json
|
1754
1752
|
- spec/support/markdown_pact_with_html.json
|
1755
1753
|
- spec/support/markdown_pact_with_markdown_chars_in_names.json
|
1756
1754
|
- spec/support/metadata_test_server.rb
|