pact_broker 2.43.0 → 2.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -1
- data/DEVELOPER_DOCUMENTATION.md +10 -6
- data/README.md +1 -1
- data/lib/pact_broker/api.rb +2 -2
- data/lib/pact_broker/api/decorators/version_decorator.rb +8 -0
- data/lib/pact_broker/db/models.rb +1 -1
- data/lib/pact_broker/doc/views/matrix.markdown +92 -2
- data/lib/pact_broker/matrix/deployment_status_summary.rb +11 -2
- data/lib/pact_broker/matrix/every_row.rb +43 -0
- data/lib/pact_broker/matrix/query_builder.rb +5 -5
- data/lib/pact_broker/matrix/quick_row.rb +96 -28
- data/lib/pact_broker/matrix/reason.rb +3 -0
- data/lib/pact_broker/matrix/repository.rb +33 -35
- data/lib/pact_broker/pacticipants/repository.rb +9 -1
- data/lib/pact_broker/pacts/{latest_pact_publication_id_by_consumer_version.rb → latest_pact_publication_id_for_consumer_version.rb} +0 -0
- data/lib/pact_broker/pacts/repository.rb +1 -1
- data/lib/pact_broker/repositories/helpers.rb +12 -5
- data/lib/pact_broker/version.rb +1 -1
- data/pact_broker.gemspec +1 -1
- data/spec/lib/pact_broker/integrations/service_spec.rb +1 -0
- data/spec/lib/pact_broker/matrix/deployment_status_summary_spec.rb +38 -33
- data/spec/lib/pact_broker/matrix/every_row_spec.rb +136 -0
- data/spec/lib/pact_broker/matrix/integration_spec.rb +149 -30
- data/spec/lib/pact_broker/matrix/repository_dependency_spec.rb +3 -3
- data/spec/lib/pact_broker/matrix/repository_spec.rb +5 -4
- data/spec/lib/pact_broker/pacticipants/repository_spec.rb +37 -3
- data/spec/service_consumers/provider_states_for_pact_ruby.rb +12 -0
- data/spec/support/shared_examples_for_responses.rb +7 -0
- metadata +14 -5
@@ -37,6 +37,9 @@ module PactBroker
|
|
37
37
|
# the required provider version
|
38
38
|
# (this row is not included in the matrix, and it's
|
39
39
|
# absence must be inferred)
|
40
|
+
# Update: because the left outer join now returns a row with blank verification
|
41
|
+
# details, this scenario is now indistingishable from PactNotEverVerifiedByProvider
|
42
|
+
# TODO: merge these two classes when it's verified that they are duplicates.
|
40
43
|
class PactNotVerifiedByRequiredProviderVersion < ErrorReasonWithTwoSelectors; end
|
41
44
|
|
42
45
|
# The pact verification has failed
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'pact_broker/repositories/helpers'
|
2
2
|
require 'pact_broker/matrix/row'
|
3
3
|
require 'pact_broker/matrix/quick_row'
|
4
|
+
require 'pact_broker/matrix/every_row'
|
4
5
|
require 'pact_broker/matrix/head_row'
|
5
6
|
require 'pact_broker/error'
|
6
7
|
require 'pact_broker/matrix/query_results'
|
@@ -53,9 +54,16 @@ module PactBroker
|
|
53
54
|
|
54
55
|
# Return the latest matrix row (pact/verification) for each consumer_version_number/provider_version_number
|
55
56
|
def find specified_selectors, options = {}
|
56
|
-
|
57
|
-
|
58
|
-
|
57
|
+
resolved_specified_selectors = resolve_versions_and_add_ids(specified_selectors, :specified)
|
58
|
+
integrations = find_integrations_for_specified_selectors(resolved_specified_selectors)
|
59
|
+
resolved_selectors = if infer_selectors_for_integrations?(options)
|
60
|
+
resolved_specified_selectors + inferred_selectors(resolved_specified_selectors, integrations, options)
|
61
|
+
else
|
62
|
+
resolved_specified_selectors
|
63
|
+
end
|
64
|
+
|
65
|
+
all_lines = query_matrix(resolved_selectors, options)
|
66
|
+
lines = apply_latestby(options, all_lines)
|
59
67
|
|
60
68
|
# This needs to be done after the latestby, so can't be done in the db unless
|
61
69
|
# the latestby logic is moved to the db
|
@@ -63,7 +71,6 @@ module PactBroker
|
|
63
71
|
lines = lines.select{ |l| options[:success].include?(l.success) }
|
64
72
|
end
|
65
73
|
|
66
|
-
integrations = find_integrations_for_specified_selectors(resolved_selectors.select(&:specified?))
|
67
74
|
QueryResults.new(lines.sort, specified_selectors, options, resolved_selectors, integrations)
|
68
75
|
end
|
69
76
|
|
@@ -101,7 +108,7 @@ module PactBroker
|
|
101
108
|
end
|
102
109
|
|
103
110
|
# It would be nicer to do this in the SQL, but it requires time that I don't have at the moment
|
104
|
-
def apply_latestby options,
|
111
|
+
def apply_latestby options, lines
|
105
112
|
return lines unless options[:latestby]
|
106
113
|
group_by_columns = case options[:latestby]
|
107
114
|
when 'cvpv' then GROUP_BY_PROVIDER_VERSION_NUMBER
|
@@ -118,39 +125,34 @@ module PactBroker
|
|
118
125
|
end
|
119
126
|
|
120
127
|
def query_matrix selectors, options
|
121
|
-
query = options
|
122
|
-
|
128
|
+
query = base_model(options)
|
129
|
+
.select_all_columns
|
130
|
+
.matching_selectors(selectors)
|
131
|
+
.order_by_names_ascending_most_recent_first
|
123
132
|
query = query.limit(options[:limit]) if options[:limit]
|
124
|
-
query
|
125
|
-
.order_by_names_ascending_most_recent_first
|
126
|
-
.eager(:consumer_version_tags)
|
127
|
-
.eager(:provider_version_tags)
|
128
|
-
.all
|
133
|
+
query.eager_all_the_things.all
|
129
134
|
end
|
130
135
|
|
131
|
-
def
|
132
|
-
|
133
|
-
if options[:latest] || options[:tag]
|
134
|
-
add_inferred_selectors(resolved_specified_selectors, options)
|
135
|
-
else
|
136
|
-
resolved_specified_selectors
|
137
|
-
end
|
136
|
+
def base_model(options)
|
137
|
+
options[:latestby] ? QuickRow : EveryRow
|
138
138
|
end
|
139
139
|
|
140
140
|
# Find the version number for selectors with the latest and/or tag specified
|
141
|
-
def resolve_versions_and_add_ids(selectors, selector_type
|
141
|
+
def resolve_versions_and_add_ids(selectors, selector_type)
|
142
142
|
selectors.collect do | selector |
|
143
143
|
pacticipant = PactBroker::Domain::Pacticipant.find(name: selector[:pacticipant_name])
|
144
144
|
versions = find_versions_for_selector(selector)
|
145
|
-
|
145
|
+
build_resolved_selectors(pacticipant, versions, selector, selector_type)
|
146
146
|
end.flatten
|
147
147
|
end
|
148
148
|
|
149
|
-
|
149
|
+
# When a single selector specifies multiple versions (eg. "all prod pacts"), this expands
|
150
|
+
# the single selector into one selector for each version.
|
151
|
+
def build_resolved_selectors(pacticipant, versions, original_selector, selector_type)
|
150
152
|
if versions
|
151
153
|
versions.collect do | version |
|
152
154
|
if version
|
153
|
-
selector_for_version(pacticipant, version, original_selector, selector_type
|
155
|
+
selector_for_version(pacticipant, version, original_selector, selector_type)
|
154
156
|
else
|
155
157
|
selector_for_non_existing_version(pacticipant, original_selector, selector_type)
|
156
158
|
end
|
@@ -178,14 +180,17 @@ module PactBroker
|
|
178
180
|
end
|
179
181
|
end
|
180
182
|
|
183
|
+
def infer_selectors_for_integrations?(options)
|
184
|
+
options[:latest] || options[:tag]
|
185
|
+
end
|
186
|
+
|
181
187
|
# When only one selector is specified, (eg. checking to see if Foo version 2 can be deployed to prod),
|
182
188
|
# need to look up all integrated pacticipants, and determine their relevant (eg. latest prod) versions
|
183
|
-
def
|
184
|
-
integrations = find_integrations_for_specified_selectors(resolved_specified_selectors)
|
189
|
+
def inferred_selectors(resolved_specified_selectors, integrations, options)
|
185
190
|
all_pacticipant_names = integrations.collect(&:pacticipant_names).flatten.uniq
|
186
191
|
specified_names = resolved_specified_selectors.collect{ |s| s[:pacticipant_name] }
|
187
192
|
inferred_pacticipant_names = all_pacticipant_names - specified_names
|
188
|
-
|
193
|
+
build_inferred_selectors(inferred_pacticipant_names, options)
|
189
194
|
end
|
190
195
|
|
191
196
|
def build_inferred_selectors(inferred_pacticipant_names, options)
|
@@ -197,21 +202,14 @@ module PactBroker
|
|
197
202
|
selector[:latest] = options[:latest] if options[:latest]
|
198
203
|
selector
|
199
204
|
end
|
200
|
-
resolve_versions_and_add_ids(selectors, :inferred
|
201
|
-
end
|
202
|
-
|
203
|
-
def all_pacticipant_names_in_specified_matrix(selectors)
|
204
|
-
find_integrations_for_specified_selectors(selectors)
|
205
|
-
.collect(&:pacticipant_names)
|
206
|
-
.flatten
|
207
|
-
.uniq
|
205
|
+
resolve_versions_and_add_ids(selectors, :inferred)
|
208
206
|
end
|
209
207
|
|
210
208
|
def selector_for_non_existing_version(pacticipant, original_selector, selector_type)
|
211
209
|
ResolvedSelector.for_pacticipant_and_non_existing_version(pacticipant, original_selector, selector_type)
|
212
210
|
end
|
213
211
|
|
214
|
-
def selector_for_version(pacticipant, version, original_selector, selector_type
|
212
|
+
def selector_for_version(pacticipant, version, original_selector, selector_type)
|
215
213
|
ResolvedSelector.for_pacticipant_and_version(pacticipant, version, original_selector, selector_type)
|
216
214
|
end
|
217
215
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'sequel'
|
2
2
|
require 'pact_broker/domain/pacticipant'
|
3
3
|
require 'pact_broker/repositories/helpers'
|
4
|
+
require 'pact_broker/error'
|
4
5
|
|
5
6
|
module PactBroker
|
6
7
|
module Pacticipants
|
@@ -9,7 +10,9 @@ module PactBroker
|
|
9
10
|
include PactBroker::Repositories::Helpers
|
10
11
|
|
11
12
|
def find_by_name name
|
12
|
-
PactBroker::Domain::Pacticipant.where(name_like(:name, name)).
|
13
|
+
pacticipants = PactBroker::Domain::Pacticipant.where(name_like(:name, name)).all
|
14
|
+
handle_multiple_pacticipants_found(name, pacticipants) if pacticipants.size > 1
|
15
|
+
pacticipants.first
|
13
16
|
end
|
14
17
|
|
15
18
|
def find_by_id id
|
@@ -66,6 +69,11 @@ module PactBroker
|
|
66
69
|
pacticipant.destroy
|
67
70
|
end
|
68
71
|
end
|
72
|
+
|
73
|
+
def handle_multiple_pacticipants_found(name, pacticipants)
|
74
|
+
names = pacticipants.collect(&:name).join(", ")
|
75
|
+
raise PactBroker::Error.new("Found multiple pacticipants with a case insensitive name match for '#{name}': #{names}. Please delete one of them, or set PactBroker.configuration.use_case_sensitive_resource_names = true")
|
76
|
+
end
|
69
77
|
end
|
70
78
|
end
|
71
79
|
end
|
File without changes
|
@@ -11,7 +11,7 @@ require 'pact/shared/json_differ'
|
|
11
11
|
require 'pact_broker/domain'
|
12
12
|
require 'pact_broker/pacts/parse'
|
13
13
|
require 'pact_broker/matrix/head_row'
|
14
|
-
require 'pact_broker/pacts/
|
14
|
+
require 'pact_broker/pacts/latest_pact_publication_id_for_consumer_version'
|
15
15
|
require 'pact_broker/pacts/verifiable_pact'
|
16
16
|
|
17
17
|
module PactBroker
|
@@ -1,3 +1,5 @@
|
|
1
|
+
Sequel.extension :escaped_like
|
2
|
+
|
1
3
|
module PactBroker
|
2
4
|
module Repositories
|
3
5
|
module Helpers
|
@@ -5,11 +7,16 @@ module PactBroker
|
|
5
7
|
extend self
|
6
8
|
|
7
9
|
def name_like column_name, value
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
if PactBroker.configuration.use_case_sensitive_resource_names
|
11
|
+
if mysql?
|
12
|
+
# sigh, mysql, this is the only way to perform a case sensitive search
|
13
|
+
Sequel.like(column_name, value.gsub("_", "\\_"), { case_insensitive: false })
|
14
|
+
else
|
15
|
+
{ column_name => value }
|
16
|
+
end
|
17
|
+
else
|
18
|
+
Sequel.like(column_name, value.gsub("_", "\\_"), { case_insensitive: true })
|
19
|
+
end
|
13
20
|
end
|
14
21
|
|
15
22
|
def order_ignore_case column_name = :name
|
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.0.8', '~>2.0'
|
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.12', '>= 1.12.1'
|
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'
|
@@ -16,35 +16,37 @@ module PactBroker
|
|
16
16
|
|
17
17
|
describe ".call" do
|
18
18
|
let(:rows) { [row_1, row_2] }
|
19
|
+
# Foo => Bar
|
19
20
|
let(:row_1) do
|
20
21
|
double(Row,
|
21
22
|
consumer: foo,
|
22
23
|
provider: bar,
|
23
24
|
consumer_version: foo_version,
|
24
25
|
provider_version: bar_version,
|
25
|
-
consumer_name:
|
26
|
-
consumer_id:
|
27
|
-
consumer_version_id:
|
28
|
-
provider_name:
|
29
|
-
provider_id:
|
26
|
+
consumer_name: foo.name,
|
27
|
+
consumer_id: foo.id,
|
28
|
+
consumer_version_id: foo_version.id,
|
29
|
+
provider_name: bar.name,
|
30
|
+
provider_id: bar.id,
|
30
31
|
success: row_1_success,
|
31
|
-
pacticipant_names:
|
32
|
+
pacticipant_names: [foo.name, bar.name]
|
32
33
|
)
|
33
34
|
end
|
34
35
|
|
36
|
+
# Foo => Baz
|
35
37
|
let(:row_2) do
|
36
38
|
double(Row,
|
37
39
|
consumer: foo,
|
38
40
|
provider: baz,
|
39
41
|
consumer_version: foo_version,
|
40
42
|
provider_version: baz_version,
|
41
|
-
consumer_name:
|
42
|
-
consumer_id:
|
43
|
-
consumer_version_id:
|
44
|
-
provider_name:
|
45
|
-
provider_id:
|
43
|
+
consumer_name: foo.name,
|
44
|
+
consumer_id: foo.id,
|
45
|
+
consumer_version_id: foo_version.id,
|
46
|
+
provider_name: baz.name,
|
47
|
+
provider_id: baz.id,
|
46
48
|
success: true,
|
47
|
-
pacticipant_names:
|
49
|
+
pacticipant_names: [foo.name, baz.name]
|
48
50
|
)
|
49
51
|
end
|
50
52
|
|
@@ -61,29 +63,29 @@ module PactBroker
|
|
61
63
|
let(:bar) { double('bar', id: 2, name: "Bar") }
|
62
64
|
let(:baz) { double('baz', id: 3, name: "Baz") }
|
63
65
|
let(:foo_version) { double('foo version', number: "ddec8101dabf4edf9125a69f9a161f0f294af43c", id: 10)}
|
64
|
-
let(:bar_version) { double('bar version', number: "14131c5da3abf323ccf410b1b619edac76231243", id:
|
65
|
-
let(:baz_version) { double('baz version', number: "4ee06460f10e8207ad904fa9fa6c4842e462ab59", id:
|
66
|
+
let(:bar_version) { double('bar version', number: "14131c5da3abf323ccf410b1b619edac76231243", id: 11)}
|
67
|
+
let(:baz_version) { double('baz version', number: "4ee06460f10e8207ad904fa9fa6c4842e462ab59", id: 12)}
|
66
68
|
|
67
69
|
let(:resolved_selectors) do
|
68
70
|
[
|
69
71
|
ResolvedSelector.new(
|
70
|
-
pacticipant_id:
|
71
|
-
pacticipant_name:
|
72
|
-
pacticipant_version_number:
|
73
|
-
pacticipant_version_id:
|
72
|
+
pacticipant_id: foo.id,
|
73
|
+
pacticipant_name: foo.name,
|
74
|
+
pacticipant_version_number: foo_version.number,
|
75
|
+
pacticipant_version_id: foo_version.id
|
74
76
|
),
|
75
77
|
ResolvedSelector.new(
|
76
|
-
pacticipant_id:
|
77
|
-
pacticipant_name:
|
78
|
-
pacticipant_version_number:
|
79
|
-
pacticipant_version_id:
|
78
|
+
pacticipant_id: bar.id,
|
79
|
+
pacticipant_name: bar.name,
|
80
|
+
pacticipant_version_number: bar_version.number,
|
81
|
+
pacticipant_version_id: bar_version.id
|
80
82
|
),
|
81
83
|
ResolvedSelector.new(
|
82
|
-
pacticipant_id:
|
83
|
-
pacticipant_name:
|
84
|
-
pacticipant_version_number:
|
85
|
-
pacticipant_version_id:
|
86
|
-
)
|
84
|
+
pacticipant_id: baz.id,
|
85
|
+
pacticipant_name: baz.name,
|
86
|
+
pacticipant_version_number: baz_version.number,
|
87
|
+
pacticipant_version_id: baz_version.id
|
88
|
+
)
|
87
89
|
]
|
88
90
|
end
|
89
91
|
|
@@ -132,12 +134,15 @@ module PactBroker
|
|
132
134
|
its(:counts) { is_expected.to eq success: 1, failed: 0, unknown: 1 }
|
133
135
|
end
|
134
136
|
|
135
|
-
|
137
|
+
# I think this is an impossible scenario now that the left outer join returns a row with blank verification fields
|
138
|
+
context "when there is a consumer row missing a verification and only the provider was specified in the query" do
|
139
|
+
|
136
140
|
let(:rows) { [row_1] }
|
141
|
+
|
137
142
|
let(:integrations) do
|
138
143
|
[
|
139
144
|
Integration.new(1, "Foo", 2, "Bar", true),
|
140
|
-
Integration.new(3, "Baz", 2, "Bar", false) # the missing
|
145
|
+
Integration.new(3, "Baz", 2, "Bar", false) # the integration missing a verification
|
141
146
|
]
|
142
147
|
end
|
143
148
|
|
@@ -186,10 +191,10 @@ module PactBroker
|
|
186
191
|
|
187
192
|
let(:dummy_selector) do
|
188
193
|
ResolvedSelector.new(
|
189
|
-
pacticipant_id:
|
190
|
-
pacticipant_name:
|
191
|
-
pacticipant_version_id:
|
192
|
-
pacticipant_version_number:
|
194
|
+
pacticipant_id: bar.id,
|
195
|
+
pacticipant_name: bar.name,
|
196
|
+
pacticipant_version_id: bar_version.id,
|
197
|
+
pacticipant_version_number: bar_version.number,
|
193
198
|
latest: nil,
|
194
199
|
tag: nil,
|
195
200
|
type: :inferred
|
@@ -0,0 +1,136 @@
|
|
1
|
+
require 'pact_broker/matrix/every_row'
|
2
|
+
require 'pact_broker/matrix/resolved_selector'
|
3
|
+
|
4
|
+
module PactBroker
|
5
|
+
module Matrix
|
6
|
+
describe EveryRow do
|
7
|
+
let(:foo) { PactBroker::Domain::Pacticipant.where(name: "Foo").single_record }
|
8
|
+
let(:bar) { PactBroker::Domain::Pacticipant.where(name: "Bar").single_record }
|
9
|
+
let(:wiffle) { PactBroker::Domain::Pacticipant.where(name: "Wiffle").single_record }
|
10
|
+
|
11
|
+
describe "matching_selectors" do
|
12
|
+
before do
|
13
|
+
td.create_pact_with_verification("Foo", "1", "Bar", "2")
|
14
|
+
.create_consumer_version("2")
|
15
|
+
.create_pact
|
16
|
+
.create_provider("Wiffle")
|
17
|
+
.create_pact
|
18
|
+
.create_verification(provider_version: "5")
|
19
|
+
end
|
20
|
+
|
21
|
+
let(:selector_1) do
|
22
|
+
PactBroker::Matrix::ResolvedSelector.for_pacticipant(foo, :specified)
|
23
|
+
end
|
24
|
+
|
25
|
+
let(:selector_2) do
|
26
|
+
PactBroker::Matrix::ResolvedSelector.for_pacticipant(bar, :specified)
|
27
|
+
end
|
28
|
+
|
29
|
+
let(:selectors) { [selector_1, selector_2] }
|
30
|
+
|
31
|
+
subject { EveryRow.select_all_columns.matching_selectors(selectors).all }
|
32
|
+
|
33
|
+
let(:un_verified_row) { subject.find{ |r| r.provider_id == bar.id && !r.has_verification? } }
|
34
|
+
let(:verified_row) { subject.find{ |r| r.provider_id == bar.id && r.has_verification? } }
|
35
|
+
|
36
|
+
it "includes the verified and unverified rows" do
|
37
|
+
expect(subject.size).to eq 2
|
38
|
+
expect(un_verified_row).to_not be nil
|
39
|
+
expect(verified_row).to_not be nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "eager_all_the_things" do
|
44
|
+
before do
|
45
|
+
td.create_pact_with_verification("Foo", "1", "Bar", "2")
|
46
|
+
.create_consumer_version_tag("foo")
|
47
|
+
.create_provider_version_tag("foo")
|
48
|
+
end
|
49
|
+
|
50
|
+
subject do
|
51
|
+
EveryRow
|
52
|
+
.select_all_columns
|
53
|
+
.join_verifications
|
54
|
+
.join_pacticipants_and_pacticipant_versions
|
55
|
+
.eager_all_the_things
|
56
|
+
.all
|
57
|
+
end
|
58
|
+
|
59
|
+
it "can eager load all the things" do
|
60
|
+
expect(subject.first.provider_version).to_not be nil
|
61
|
+
expect(subject.first.provider_version_id).to_not be nil
|
62
|
+
expect(subject.first.consumer_version).to_not be nil
|
63
|
+
expect(subject.first.consumer_version_id).to_not be nil
|
64
|
+
expect(subject.first.provider_version_id).to_not be nil
|
65
|
+
expect(subject.first.consumer_version_id).to_not be nil
|
66
|
+
expect(subject.first.pact_publication_id).to_not be nil
|
67
|
+
expect(subject.first.pact_version_id).to_not be nil
|
68
|
+
expect(subject.first.verification_id).to_not be nil
|
69
|
+
expect(subject.first.provider).to_not be nil
|
70
|
+
expect(subject.first.consumer).to_not be nil
|
71
|
+
expect(subject.first.consumer_version).to_not be nil
|
72
|
+
expect(subject.first.provider_version).to_not be nil
|
73
|
+
expect(subject.first.pact_version).to_not be nil
|
74
|
+
expect(subject.first.verification).to_not be nil
|
75
|
+
expect(subject.first.pact_revision_number).to_not be nil
|
76
|
+
expect(subject.first.verification_number).to_not be nil
|
77
|
+
expect(subject.first.consumer_version_tags).to_not be_empty
|
78
|
+
expect(subject.first.provider_version_tags).to_not be_empty
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
describe "join_verifications" do
|
84
|
+
before do
|
85
|
+
td.create_pact_with_verification("Foo", "1", "Bar", "2")
|
86
|
+
.create_provider("Wiffle")
|
87
|
+
.create_pact
|
88
|
+
.create_verification(provider_version: "5")
|
89
|
+
end
|
90
|
+
|
91
|
+
subject do
|
92
|
+
EveryRow
|
93
|
+
.select_all_columns
|
94
|
+
.join_verifications
|
95
|
+
.join_pacticipants_and_pacticipant_versions
|
96
|
+
.all
|
97
|
+
end
|
98
|
+
|
99
|
+
it "joins all the verifications" do
|
100
|
+
expect(subject.size).to eq 2
|
101
|
+
expect(subject.all?(&:has_verification?)).to be true
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "join_verifications_for" do
|
106
|
+
before do
|
107
|
+
td.create_pact_with_verification("Foo", "1", "Bar", "2")
|
108
|
+
.create_provider("Wiffle")
|
109
|
+
.create_pact
|
110
|
+
.create_verification(provider_version: "5")
|
111
|
+
end
|
112
|
+
|
113
|
+
let(:query_ids) do
|
114
|
+
double('query_ids',
|
115
|
+
all_pacticipant_ids: [foo.id, bar.id],
|
116
|
+
pacticipant_version_ids: [],
|
117
|
+
pacticipant_ids: [foo.id, bar.id]
|
118
|
+
)
|
119
|
+
end
|
120
|
+
|
121
|
+
subject do
|
122
|
+
EveryRow
|
123
|
+
.select_all_columns
|
124
|
+
.join_verifications_for(query_ids)
|
125
|
+
.join_pacticipants_and_pacticipant_versions
|
126
|
+
.all
|
127
|
+
end
|
128
|
+
|
129
|
+
it "pre-filters the verifications before joining them" do
|
130
|
+
expect(subject.size).to eq 2
|
131
|
+
expect(subject.find{ |r| r.provider_id == wiffle.id && !r.has_verification? }).to_not be nil
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|