pact_broker 2.8.0.beta.4 → 2.8.0.beta.5
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 +18 -2
- data/DEVELOPER_DOCUMENTATION.md +4 -0
- data/README.md +2 -1
- data/db/migrations/000048_create_matrix.rb +39 -0
- data/db/migrations/000049_create_latest_verifications_for_cv_and_pv.rb +17 -0
- data/db/migrations/000050_create_latest_matrix.rb +27 -0
- data/lib/pact_broker/api/decorators/matrix_decorator.rb +7 -5
- data/lib/pact_broker/api/decorators/matrix_text_decorator.rb +6 -3
- data/lib/pact_broker/matrix/latest_row.rb +24 -0
- data/lib/pact_broker/matrix/parse_query.rb +9 -0
- data/lib/pact_broker/matrix/repository.rb +49 -24
- data/lib/pact_broker/matrix/row.rb +46 -0
- data/lib/pact_broker/ui/controllers/matrix.rb +1 -1
- data/lib/pact_broker/ui/view_models/matrix_line.rb +2 -2
- data/lib/pact_broker/version.rb +1 -1
- data/script/seed-matrix.rb +20 -13
- data/spec/lib/pact_broker/api/decorators/matrix_decorator_spec.rb +16 -4
- data/spec/lib/pact_broker/matrix/repository_spec.rb +311 -51
- data/spec/lib/pact_broker/matrix/row_spec.rb +51 -0
- data/spec/migrations/50_create_latest_matrix_spec.rb +113 -0
- data/spec/migrations/change_migration_strategy_spec.rb +1 -1
- data/spec/service_consumers/provider_states_for_pact_broker_client.rb +31 -11
- data/spec/support/shared_examples_for_responses.rb +19 -0
- metadata +11 -2
data/lib/pact_broker/version.rb
CHANGED
data/script/seed-matrix.rb
CHANGED
@@ -42,8 +42,9 @@ A -> B -> C
|
|
42
42
|
TestDataBuilder.new
|
43
43
|
.create_pact_with_hierarchy("A", "1", "B")
|
44
44
|
.create_verification(provider_version: '1', success: false)
|
45
|
-
.create_verification(provider_version: '
|
46
|
-
.create_verification(provider_version: '
|
45
|
+
.create_verification(provider_version: '1', number: 2, success: true)
|
46
|
+
.create_verification(provider_version: '2', number: 3)
|
47
|
+
.create_verification(provider_version: '4', number: 4)
|
47
48
|
.create_provider_version("5")
|
48
49
|
.use_consumer("B")
|
49
50
|
.use_consumer_version("1")
|
@@ -55,17 +56,23 @@ TestDataBuilder.new
|
|
55
56
|
.create_verification(provider_version: '2', success: true)
|
56
57
|
.create_consumer_version("3")
|
57
58
|
.create_pact
|
58
|
-
.
|
59
|
-
.
|
60
|
-
.
|
61
|
-
.create_verification(provider_version: '4', number: 3)
|
62
|
-
.use_consumer("another-example-application")
|
63
|
-
.use_consumer_version("391c43cae8c0e83c570c191f7324fccd67e53abc")
|
64
|
-
.create_provider("a-third-example-application")
|
59
|
+
.use_consumer("A")
|
60
|
+
.create_consumer_version("2")
|
61
|
+
.use_provider("B")
|
65
62
|
.create_pact
|
66
|
-
.create_verification(provider_version: '
|
67
|
-
|
68
|
-
.
|
69
|
-
.create_verification(provider_version: '
|
63
|
+
.create_verification(provider_version: '5')
|
64
|
+
|
65
|
+
# .create_pact_with_hierarchy("the-example-application", "391c43cae8c0e83c570c191f7324fccd67e53abc", "another-example-application")
|
66
|
+
# .create_verification(provider_version: '391c43cae8c0e83c570c191f7324fccd67e53abc')
|
67
|
+
# .create_verification(provider_version: '57fa24e44efc4d8aa42bb855a8217f145b5b1b5b', number: 2, success: false)
|
68
|
+
# .create_verification(provider_version: '4', number: 3)
|
69
|
+
# .use_consumer("another-example-application")
|
70
|
+
# .use_consumer_version("391c43cae8c0e83c570c191f7324fccd67e53abc")
|
71
|
+
# .create_provider("a-third-example-application")
|
72
|
+
# .create_pact
|
73
|
+
# .create_verification(provider_version: '391c43cae8c0e83c570c191f7324fccd67e53abc', success: false)
|
74
|
+
# .use_consumer_version("57fa24e44efc4d8aa42bb855a8217f145b5b1b5b")
|
75
|
+
# .create_pact
|
76
|
+
# .create_verification(provider_version: '57fa24e44efc4d8aa42bb855a8217f145b5b1b5b', success: true)
|
70
77
|
|
71
78
|
|
@@ -18,8 +18,8 @@ module PactBroker
|
|
18
18
|
provider_version_number: "4.5.6",
|
19
19
|
provider_name: "Provider",
|
20
20
|
success: line_1_success,
|
21
|
-
|
22
|
-
|
21
|
+
verification_number: 1,
|
22
|
+
verification_build_url: nil,
|
23
23
|
verification_executed_at: verification_date
|
24
24
|
}
|
25
25
|
end
|
@@ -33,8 +33,8 @@ module PactBroker
|
|
33
33
|
provider_version_number: nil,
|
34
34
|
provider_name: "Provider",
|
35
35
|
success: line_2_success,
|
36
|
-
|
37
|
-
|
36
|
+
verification_number: nil,
|
37
|
+
verification_build_url: nil,
|
38
38
|
verification_executed_at: verification_date
|
39
39
|
}
|
40
40
|
end
|
@@ -160,6 +160,18 @@ module PactBroker
|
|
160
160
|
expect(parsed_json[:summary][:reason]).to match /have failed/
|
161
161
|
end
|
162
162
|
end
|
163
|
+
|
164
|
+
context "when there are no results" do
|
165
|
+
let(:lines) { [] }
|
166
|
+
|
167
|
+
it "has a deployable flag of false" do
|
168
|
+
expect(parsed_json[:summary][:deployable]).to be nil
|
169
|
+
end
|
170
|
+
|
171
|
+
it "has an explanation" do
|
172
|
+
expect(parsed_json[:summary][:reason]).to match /No results/
|
173
|
+
end
|
174
|
+
end
|
163
175
|
end
|
164
176
|
end
|
165
177
|
end
|
@@ -11,7 +11,265 @@ module PactBroker
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
def shorten_row row
|
15
|
+
"#{row[:consumer_name]}#{row[:consumer_version_number]} #{row[:provider_name]}#{row[:provider_version_number] || '?'} n#{row[:verification_number] || '?'}"
|
16
|
+
end
|
17
|
+
|
18
|
+
def shorten_rows rows
|
19
|
+
rows.collect{ |r| shorten_row(r) }
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "find" do
|
23
|
+
before do
|
24
|
+
# A1 - B1
|
25
|
+
# A1 - B1 r2
|
26
|
+
# A1 - B2 r3
|
27
|
+
# A1 - C1
|
28
|
+
# A2 - B?
|
29
|
+
# A2 - C2
|
30
|
+
td.create_pact_with_hierarchy("A", "1", "B")
|
31
|
+
.create_verification(provider_version: '1', success: false)
|
32
|
+
.create_verification(provider_version: '1', number: 2, success: true)
|
33
|
+
.create_verification(provider_version: '2', number: 3, success: true)
|
34
|
+
.create_provider("C")
|
35
|
+
.create_pact
|
36
|
+
.create_verification(provider_version: '1')
|
37
|
+
.create_consumer_version("2")
|
38
|
+
.create_pact
|
39
|
+
.create_verification(provider_version: '3')
|
40
|
+
.use_provider("B")
|
41
|
+
.create_pact
|
42
|
+
end
|
43
|
+
|
44
|
+
subject { shorten_rows(Repository.new.find(selectors, options)) }
|
45
|
+
|
46
|
+
let(:options) { { latestby: latestby } }
|
47
|
+
let(:latestby) { nil }
|
48
|
+
let(:a1_b1_n1) { "A1 B1 n1" }
|
49
|
+
let(:a1_b1_n2) { "A1 B1 n2" }
|
50
|
+
let(:a1_b2_n3) { "A1 B2 n3" }
|
51
|
+
let(:a1_c1_n1) { "A1 C1 n1" }
|
52
|
+
let(:a2_b__n_) { "A2 B? n?" }
|
53
|
+
|
54
|
+
context "when a limit is specified" do
|
55
|
+
let(:selectors) { build_selectors('A' => nil) }
|
56
|
+
let(:options) { {limit: 1} }
|
57
|
+
|
58
|
+
it "returns fewer rows than the limit (because some of the logic is done in the code, there may be fewer than the limit - need to fix this)" do
|
59
|
+
expect(subject).to eq ["A2 B? n?"]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context "when just the consumer name is specified" do
|
64
|
+
let(:selectors) { build_selectors('A' => nil) }
|
65
|
+
|
66
|
+
context "when no latestby is specified" do
|
67
|
+
it "returns all rows" do
|
68
|
+
expect(subject).to include a1_b1_n1
|
69
|
+
expect(subject).to include a1_b1_n2
|
70
|
+
expect(subject).to include a1_c1_n1
|
71
|
+
expect(subject).to include a2_b__n_
|
72
|
+
expect(subject.size).to eq 6
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context "when latestby=cvpv" do
|
77
|
+
let(:latestby) { 'cvpv' }
|
78
|
+
|
79
|
+
it "returns the latest rows per consumer version/provider version" do
|
80
|
+
expect(subject).to_not include a1_b1_n1
|
81
|
+
expect(subject).to include a1_b1_n2
|
82
|
+
expect(subject).to include a1_c1_n1
|
83
|
+
expect(subject).to include a2_b__n_
|
84
|
+
expect(subject.size).to eq 5
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context "when latestby=cvp" do
|
89
|
+
let(:latestby) { 'cvp' }
|
90
|
+
|
91
|
+
it "returns the latest row for each provider for each consumer version" do
|
92
|
+
expect(subject).to_not include a1_b1_n1
|
93
|
+
expect(subject).to_not include a1_b1_n2
|
94
|
+
expect(subject).to include a1_b2_n3
|
95
|
+
expect(subject).to include a1_c1_n1
|
96
|
+
expect(subject).to include a2_b__n_
|
97
|
+
expect(subject.size).to eq 4
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
context "when latestby=cp", pending: true do
|
102
|
+
let(:latestby) { 'cp' }
|
103
|
+
|
104
|
+
it "returns the latest rows per consumer/provider" do
|
105
|
+
expect(subject).to include "A2 C3 n1"
|
106
|
+
expect(subject).to include "A2 B? n?"
|
107
|
+
expect(subject).to include a1_c1_n1
|
108
|
+
expect(subject).to_not include a1_b2_n3
|
109
|
+
expect(subject.size).to eq 2
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
context "when the consumer name/version are specified" do
|
115
|
+
let(:selectors) { build_selectors('A' => '1') }
|
116
|
+
|
117
|
+
context "when no latestby is specified" do
|
118
|
+
it "returns all the rows for the consumer version" do
|
119
|
+
expect(subject.size).to eq 4
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
context "when latestby=cvpv" do
|
124
|
+
let(:latestby) { 'cvpv' }
|
125
|
+
|
126
|
+
it "returns the latest verification for each provider version for the specified consumer version" do
|
127
|
+
expect(subject).to_not include a1_b1_n1
|
128
|
+
expect(subject).to include a1_b1_n2
|
129
|
+
expect(subject).to include a1_c1_n1
|
130
|
+
expect(subject.size).to eq 3
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
context "when latestby=cvp" do
|
135
|
+
let(:latestby) { 'cvp' }
|
136
|
+
|
137
|
+
it "returns the latest verifications for each provider for the specified consumer version" do
|
138
|
+
expect(subject).to_not include a1_b1_n1
|
139
|
+
expect(subject).to_not include a1_b1_n2
|
140
|
+
expect(subject).to include a1_b2_n3
|
141
|
+
expect(subject).to include a1_c1_n1
|
142
|
+
expect(subject.size).to eq 2
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
context "when latestby=cp" do
|
147
|
+
let(:latestby) { 'cp' }
|
148
|
+
|
149
|
+
it "returns the same as latestby=cvp" do
|
150
|
+
expect(subject).to_not include a1_b1_n1
|
151
|
+
expect(subject).to_not include a1_b1_n2
|
152
|
+
expect(subject).to include a1_b2_n3
|
153
|
+
expect(subject).to include a1_c1_n1
|
154
|
+
expect(subject.size).to eq 2
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
context "when the consumer name/version and the provider name are specified" do
|
160
|
+
let(:selectors) { build_selectors('A' => '1', 'B' => nil) }
|
161
|
+
|
162
|
+
context "when no latestby is specified" do
|
163
|
+
it "returns all the rows for the given consumer version and given provider" do
|
164
|
+
expect(subject).to include a1_b1_n1
|
165
|
+
expect(subject).to include a1_b1_n2
|
166
|
+
expect(subject).to include a1_b2_n3
|
167
|
+
expect(subject).to_not include a1_c1_n1
|
168
|
+
expect(subject.size).to eq 3
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
context "when latestby=cvpv" do
|
173
|
+
let(:latestby) { 'cvpv' }
|
174
|
+
|
175
|
+
it "returns the latest verification for each provider version for the given consumer version" do
|
176
|
+
expect(subject).to_not include a1_b1_n1
|
177
|
+
expect(subject).to include a1_b1_n2
|
178
|
+
expect(subject).to include a1_b2_n3
|
179
|
+
expect(subject).to_not include a1_c1_n1
|
180
|
+
expect(subject.size).to eq 2
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
context "when latestby=cvp" do
|
185
|
+
let(:latestby) { 'cvp' }
|
186
|
+
|
187
|
+
it "returns the latest verification for the given provider for the given consumer version" do
|
188
|
+
expect(subject).to_not include a1_b1_n1
|
189
|
+
expect(subject).to_not include a1_b1_n2
|
190
|
+
expect(subject).to include a1_b2_n3
|
191
|
+
expect(subject).to_not include a1_c1_n1
|
192
|
+
expect(subject.size).to eq 1
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
context "when latestby=cp" do
|
197
|
+
let(:latestby) { 'cp' }
|
198
|
+
|
199
|
+
it "returns the same as latestby=cvp" do
|
200
|
+
expect(subject).to_not include a1_b1_n1
|
201
|
+
expect(subject).to_not include a1_b1_n2
|
202
|
+
expect(subject).to include a1_b2_n3
|
203
|
+
expect(subject).to_not include a1_c1_n1
|
204
|
+
expect(subject.size).to eq 1
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
context "when the consumer name/version and provider name/version are specified" do
|
210
|
+
let(:selectors) { build_selectors('A' => '1', 'B' => '1') }
|
211
|
+
|
212
|
+
context "when no latestby is specified" do
|
213
|
+
it "returns all the rows for the given consumer/version and given provider/version" do
|
214
|
+
expect(subject).to include a1_b1_n1
|
215
|
+
expect(subject).to include a1_b1_n2
|
216
|
+
expect(subject).to_not include a1_b2_n3
|
217
|
+
expect(subject).to_not include a1_c1_n1
|
218
|
+
expect(subject.size).to eq 2
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
context "when latestby=cvpv" do
|
223
|
+
let(:latestby) { 'cvpv' }
|
224
|
+
|
225
|
+
it "returns the latest verification for the given provider version for the given consumer version" do
|
226
|
+
expect(subject).to include a1_b1_n2
|
227
|
+
expect(subject.size).to eq 1
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
context "when latestby=cvp" do
|
232
|
+
let(:latestby) { 'cvp' }
|
233
|
+
|
234
|
+
it "returns the same as latestby=cvpv" do
|
235
|
+
expect(subject).to include a1_b1_n2
|
236
|
+
expect(subject.size).to eq 1
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
context "when latestby=cp" do
|
241
|
+
let(:latestby) { 'cp' }
|
242
|
+
|
243
|
+
it "returns the same as latestby=cvp" do
|
244
|
+
expect(subject).to include a1_b1_n2
|
245
|
+
expect(subject.size).to eq 1
|
246
|
+
end
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
14
251
|
describe "find" do
|
252
|
+
let(:options) { {} }
|
253
|
+
|
254
|
+
subject { Repository.new.find(selectors, options) }
|
255
|
+
|
256
|
+
context "when a pact is revised, then verified" do
|
257
|
+
before do
|
258
|
+
td.create_pact_with_hierarchy("A", "1", "B")
|
259
|
+
.revise_pact
|
260
|
+
.create_verification(provider_version: "1")
|
261
|
+
end
|
262
|
+
|
263
|
+
context "when latestby=cvpv" do
|
264
|
+
let(:selectors) { build_selectors('A' => '1', 'B' => '1')}
|
265
|
+
let(:options) { { latestby: 'cvpv' } }
|
266
|
+
|
267
|
+
it "returns one row" do
|
268
|
+
expect(shorten_rows(subject)).to eq ['A1 B1 n1']
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
15
273
|
context "when the provider version resource exists but there is no verification for that version" do
|
16
274
|
before do
|
17
275
|
# A/1.2.3 -> B
|
@@ -24,8 +282,7 @@ module PactBroker
|
|
24
282
|
.create_version("3.0.0")
|
25
283
|
.create_pact
|
26
284
|
end
|
27
|
-
|
28
|
-
subject { Repository.new.find build_selectors("A" => "1.2.3", "B" => "2.0.0", "C" => "3.0.0") }
|
285
|
+
let(:selectors) { build_selectors("A" => "1.2.3", "B" => "2.0.0", "C" => "3.0.0") }
|
29
286
|
|
30
287
|
it "returns a row for each pact" do
|
31
288
|
expect(subject.size).to eq 2
|
@@ -46,8 +303,6 @@ module PactBroker
|
|
46
303
|
context "when only 2 version selectors are specified" do
|
47
304
|
let(:selectors) { build_selectors("A" => "1.2.3", "B" => "2.0.0") }
|
48
305
|
|
49
|
-
subject { Repository.new.find(selectors) }
|
50
|
-
|
51
306
|
it "only returns 1 row" do
|
52
307
|
expect(subject.size).to eq 1
|
53
308
|
end
|
@@ -66,7 +321,7 @@ module PactBroker
|
|
66
321
|
.create_verification(provider_version: "4.5.6")
|
67
322
|
end
|
68
323
|
|
69
|
-
|
324
|
+
let(:selectors) { build_selectors("A" => "1.2.3") }
|
70
325
|
|
71
326
|
it "returns a row for each verification for that version" do
|
72
327
|
expect(subject.size).to eq 2
|
@@ -84,7 +339,7 @@ module PactBroker
|
|
84
339
|
.create_pact_with_hierarchy("X", "1.2.3", "Y")
|
85
340
|
end
|
86
341
|
|
87
|
-
|
342
|
+
let(:selectors) { build_selectors("A" => nil) }
|
88
343
|
|
89
344
|
it "returns a row for each verification for the pacticipant" do
|
90
345
|
expect(subject.collect{|r| r[:consumer_name]}.uniq).to eq ["A"]
|
@@ -105,7 +360,7 @@ module PactBroker
|
|
105
360
|
.create_verification(provider_version: "6.7.8", number: 2)
|
106
361
|
end
|
107
362
|
|
108
|
-
|
363
|
+
let(:selectors) { build_selectors("B" => "4.5.6") }
|
109
364
|
|
110
365
|
it "returns a row for each verification for that version" do
|
111
366
|
expect(subject.size).to eq 2
|
@@ -125,7 +380,11 @@ module PactBroker
|
|
125
380
|
.create_verification(provider_version: "6.7.8", number: 2)
|
126
381
|
end
|
127
382
|
|
128
|
-
|
383
|
+
before do
|
384
|
+
options.delete(:scope)
|
385
|
+
end
|
386
|
+
|
387
|
+
let(:selectors) { build_selectors("B" => nil) }
|
129
388
|
|
130
389
|
it "returns a row for each verification for that version" do
|
131
390
|
expect(subject.size).to eq 3
|
@@ -148,7 +407,7 @@ module PactBroker
|
|
148
407
|
.create_verification(provider_version: '1', success: false)
|
149
408
|
end
|
150
409
|
|
151
|
-
|
410
|
+
let(:selectors) { build_selectors("B" => "1") }
|
152
411
|
|
153
412
|
it "returns rows where the pacticipant is the consumer and rows where the pacticipant is the provider" do
|
154
413
|
# A/1 and B/1
|
@@ -170,10 +429,10 @@ module PactBroker
|
|
170
429
|
|
171
430
|
let(:selectors) { build_selectors("A" => nil, "B" => nil) }
|
172
431
|
|
173
|
-
subject { Repository.new.find(selectors, options) }
|
174
|
-
|
175
432
|
context "when the success option is not set" do
|
176
|
-
|
433
|
+
before do
|
434
|
+
options.delete(:success)
|
435
|
+
end
|
177
436
|
|
178
437
|
it "returns all rows specified by the selectors" do
|
179
438
|
expect(subject.size).to eq 3
|
@@ -181,34 +440,42 @@ module PactBroker
|
|
181
440
|
end
|
182
441
|
|
183
442
|
context "when the success option is true" do
|
184
|
-
|
443
|
+
before do
|
444
|
+
options[:success] = [true]
|
445
|
+
end
|
185
446
|
|
186
447
|
it "only includes successes" do
|
187
|
-
expect(subject
|
448
|
+
expect(subject).to include_hash_matching provider_version_number: "1.0.0"
|
188
449
|
expect(subject.size).to eq 1
|
189
450
|
end
|
190
451
|
end
|
191
452
|
|
192
453
|
context "when the success option is false" do
|
193
|
-
|
454
|
+
before do
|
455
|
+
options[:success] = [false]
|
456
|
+
end
|
194
457
|
|
195
458
|
it "only includes failures" do
|
196
|
-
expect(subject
|
459
|
+
expect(subject).to include_hash_matching provider_version_number: "2.0.0"
|
197
460
|
expect(subject.size).to eq 1
|
198
461
|
end
|
199
462
|
end
|
200
463
|
|
201
464
|
context "when the success option is nil" do
|
202
|
-
|
465
|
+
before do
|
466
|
+
options[:success] = [nil]
|
467
|
+
end
|
203
468
|
|
204
469
|
it "only includes unverified rows" do
|
205
|
-
expect(subject
|
470
|
+
expect(subject).to include_hash_matching provider_version_number: nil
|
206
471
|
expect(subject.size).to eq 1
|
207
472
|
end
|
208
473
|
end
|
209
474
|
|
210
475
|
context "when multiple success options are specified" do
|
211
|
-
|
476
|
+
before do
|
477
|
+
options[:success] = [false, nil]
|
478
|
+
end
|
212
479
|
|
213
480
|
it "returns all matching rows" do
|
214
481
|
# postgres orders differently, and ruby array sort blows up with a nil string
|
@@ -220,7 +487,7 @@ module PactBroker
|
|
220
487
|
end
|
221
488
|
end
|
222
489
|
|
223
|
-
context "when the latest tag is specified for a provider
|
490
|
+
context "when the latest tag is specified for a provider" do
|
224
491
|
before do
|
225
492
|
td.create_pact_with_hierarchy("A", "1.2.3", "B")
|
226
493
|
.create_verification(provider_version: "1.0.0")
|
@@ -239,10 +506,8 @@ module PactBroker
|
|
239
506
|
]
|
240
507
|
end
|
241
508
|
|
242
|
-
subject { Repository.new.find(selectors) }
|
243
|
-
|
244
509
|
it "returns the row for the version " do
|
245
|
-
expect(subject
|
510
|
+
expect(subject).to include_hash_matching provider_version_number: "2.0.0"
|
246
511
|
expect(subject.size).to eq 1
|
247
512
|
end
|
248
513
|
end
|
@@ -264,10 +529,8 @@ module PactBroker
|
|
264
529
|
]
|
265
530
|
end
|
266
531
|
|
267
|
-
subject { Repository.new.find(selectors) }
|
268
|
-
|
269
532
|
it "returns the row for the version " do
|
270
|
-
expect(subject
|
533
|
+
expect(subject).to include_hash_matching provider_version_number: "3.0.0"
|
271
534
|
expect(subject.size).to eq 1
|
272
535
|
end
|
273
536
|
end
|
@@ -286,8 +549,6 @@ module PactBroker
|
|
286
549
|
]
|
287
550
|
end
|
288
551
|
|
289
|
-
subject { Repository.new.find(selectors) }
|
290
|
-
|
291
552
|
it "returns no data - this may be confusing. Might need to re-think this logic." do
|
292
553
|
expect(subject.size).to eq 0
|
293
554
|
end
|
@@ -325,6 +586,8 @@ module PactBroker
|
|
325
586
|
describe "#find_compatible_pacticipant_versions" do
|
326
587
|
let(:td) { TestDataBuilder.new }
|
327
588
|
|
589
|
+
subject { Repository.new.find(selectors, success: [true], latestby: 'cvpv')}
|
590
|
+
|
328
591
|
context "when compatible versions can be found" do
|
329
592
|
before do
|
330
593
|
td.create_pact_with_hierarchy("A", "1", "B")
|
@@ -345,34 +608,33 @@ module PactBroker
|
|
345
608
|
|
346
609
|
let(:selectors){ build_selectors("A" => "1", "B" => "2", "C" => "2") }
|
347
610
|
|
348
|
-
subject { Repository.new.find_compatible_pacticipant_versions(selectors) }
|
349
|
-
|
350
611
|
it "returns matrix lines for each compatible version pair (A/1-B/2, B/2-C/2)" do
|
351
|
-
expect(subject
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
expect(subject
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
612
|
+
expect(subject).to include_hash_matching(
|
613
|
+
consumer_name: "A",
|
614
|
+
consumer_version_number: "1",
|
615
|
+
provider_name: "B",
|
616
|
+
provider_version_number: "2",
|
617
|
+
verification_number: 2
|
618
|
+
)
|
619
|
+
|
620
|
+
expect(subject).to include_hash_matching(
|
621
|
+
consumer_name: "B",
|
622
|
+
consumer_version_number: "2",
|
623
|
+
provider_name: "C",
|
624
|
+
provider_version_number: "2",
|
625
|
+
verification_number: 1,
|
626
|
+
)
|
365
627
|
|
366
628
|
expect(subject.size).to eq 2
|
367
629
|
end
|
368
630
|
|
369
631
|
context "when one or more pacticipants does not have a version specified" do
|
370
632
|
let(:selectors){ build_selectors("A" => "1", "B" => "2", "C" => nil) }
|
371
|
-
|
633
|
+
let(:options) { { latestby: 'cvpv'} }
|
372
634
|
|
373
635
|
it "returns all the rows for that pacticipant" do
|
374
|
-
expect(subject
|
375
|
-
expect(subject
|
636
|
+
expect(subject).to include_hash_matching(provider_name: "C", provider_version_number: "2")
|
637
|
+
expect(subject).to include_hash_matching(provider_name: "C", provider_version_number: "3")
|
376
638
|
expect(subject.size).to eq 3
|
377
639
|
end
|
378
640
|
end
|
@@ -380,8 +642,6 @@ module PactBroker
|
|
380
642
|
context "none of the pacticipants have a version specified" do
|
381
643
|
let(:selectors){ build_selectors("A" => nil, "B" => nil, "C" => nil) }
|
382
644
|
|
383
|
-
subject { Repository.new.find_compatible_pacticipant_versions(selectors) }
|
384
|
-
|
385
645
|
it "returns all the rows" do
|
386
646
|
expect(subject.size).to eq 5
|
387
647
|
end
|
@@ -401,11 +661,11 @@ module PactBroker
|
|
401
661
|
|
402
662
|
it "returns the last line" do
|
403
663
|
expect(subject.size).to eq 1
|
404
|
-
expect(subject
|
664
|
+
expect(subject).to include_hash_matching verification_number: 2
|
405
665
|
end
|
406
666
|
end
|
407
667
|
|
408
|
-
context "when there is more than one
|
668
|
+
context "when there is more than one verification and the last one is a failure" do
|
409
669
|
before do
|
410
670
|
td.create_pact_with_hierarchy("X", "1", "Y")
|
411
671
|
.create_verification(provider_version: "1")
|