pact_broker 2.15.0 → 2.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +7 -3
- data/CHANGELOG.md +53 -0
- data/DEVELOPER_DOCUMENTATION.md +28 -1
- data/DEVELOPER_SETUP.md +1 -1
- data/README.md +8 -5
- data/db/migrations/000004_create_tags_table.rb +1 -1
- data/db/migrations/000050_create_latest_matrix.rb +1 -0
- data/db/migrations/20180122_create_head_pact_publications.rb +21 -0
- data/db/migrations/20180123_create_tags_with_latest_flag.rb +28 -0
- data/db/migrations/20180129_create_latest_matrix_for_cv_and_pv.rb +91 -0
- data/db/migrations/20180130_create_materialized_matrix.rb +35 -0
- data/db/migrations/20180131_create_materialized_latest_matrix.rb +35 -0
- data/db/migrations/20180201_create_head_matrix.rb +33 -0
- data/db/migrations/20180202_create_materialized_head_matrix.rb +34 -0
- data/db/migrations/20180203_fix_head_matrix.rb +36 -0
- data/db/migrations/20180204_fix_latest_matrix_for_cv_and_pv.rb +57 -0
- data/db/migrations/20180205_drop_materialized_latest_matrix.rb +36 -0
- data/db/migrations/20180206_recreate_head_matrix_rename_consumer_tag_name.rb +68 -0
- data/db/migrations/20180207_recreate_head_matrix_union_all.rb +60 -0
- data/db/migrations/20180208_add_cv_tag_name_index_to_mat_head_matrix.rb +7 -0
- data/db/migrations/20180209_recreate_latest_matrix_for_cv_and_pv_union_all.rb +54 -0
- data/db/migrations/20180210_fix_latest_matrix_for_cv_and_pv_again.rb +53 -0
- data/db/migrations/migration_helper.rb +8 -0
- data/db/test/backwards_compatibility/Rakefile +1 -1
- data/example/pact_broker_database.sqlite3 +0 -0
- data/lib/pact_broker/api.rb +1 -0
- data/lib/pact_broker/api/decorators/dashboard_decorator.rb +163 -0
- data/lib/pact_broker/api/decorators/dashboard_text_decorator.rb +50 -0
- data/lib/pact_broker/api/decorators/matrix_decorator.rb +21 -16
- data/lib/pact_broker/api/decorators/pacticipant_decorator.rb +1 -0
- data/lib/pact_broker/api/pact_broker_urls.rb +29 -0
- data/lib/pact_broker/api/resources/base_resource.rb +3 -0
- data/lib/pact_broker/api/resources/dashboard.rb +38 -0
- data/lib/pact_broker/api/resources/label.rb +0 -1
- data/lib/pact_broker/api/resources/tag.rb +0 -1
- data/lib/pact_broker/dashboard/service.rb +0 -0
- data/lib/pact_broker/domain/index_item.rb +16 -5
- data/lib/pact_broker/index/service.rb +69 -4
- data/lib/pact_broker/matrix/head_row.rb +11 -0
- data/lib/pact_broker/matrix/latest_row.rb +2 -16
- data/lib/pact_broker/matrix/repository.rb +56 -11
- data/lib/pact_broker/matrix/row.rb +166 -6
- data/lib/pact_broker/matrix/service.rb +5 -0
- data/lib/pact_broker/tags/tag_with_latest_flag.rb +18 -0
- data/lib/pact_broker/ui/controllers/index.rb +5 -2
- data/lib/pact_broker/ui/controllers/matrix.rb +3 -3
- data/lib/pact_broker/ui/view_models/index_item.rb +13 -5
- data/lib/pact_broker/ui/view_models/matrix_line.rb +77 -8
- data/lib/pact_broker/ui/view_models/matrix_lines.rb +17 -0
- data/lib/pact_broker/ui/view_models/matrix_tag.rb +42 -0
- data/lib/pact_broker/ui/views/index/show-with-tags.haml +26 -14
- data/lib/pact_broker/ui/views/index/show.haml +9 -8
- data/lib/pact_broker/ui/views/matrix/show.haml +46 -15
- data/lib/pact_broker/verifications/latest_verifications_by_consumer_version.rb +1 -0
- data/lib/pact_broker/verifications/repository.rb +4 -4
- data/lib/pact_broker/version.rb +1 -1
- data/lib/pact_broker/versions/abbreviate_number.rb +14 -0
- data/pact_broker.gemspec +3 -2
- data/public/images/logo@2x.png +0 -0
- data/public/javascripts/matrix.js +5 -0
- data/public/stylesheets/index.css +33 -1
- data/public/stylesheets/matrix.css +9 -0
- data/script/db-spec.sh +1 -1
- data/spec/features/get_dashboard_spec.rb +29 -0
- data/spec/fixtures/dashboard.json +83 -0
- data/spec/lib/pact_broker/api/decorators/dashboard_decorator_spec.rb +89 -0
- data/spec/lib/pact_broker/api/decorators/matrix_decorator_spec.rb +30 -26
- data/spec/lib/pact_broker/api/resources/dashboard_spec.rb +16 -0
- data/spec/lib/pact_broker/api/resources/group_spec.rb +1 -0
- data/spec/lib/pact_broker/index/service_spec.rb +146 -32
- data/spec/lib/pact_broker/matrix/repository_spec.rb +48 -1
- data/spec/lib/pact_broker/matrix/row_spec.rb +59 -0
- data/spec/lib/pact_broker/ui/view_models/index_item_spec.rb +17 -12
- data/spec/lib/pact_broker/versions/abbreviate_number_spec.rb +22 -0
- data/spec/migrations/20180201_create_head_matrix_spec.rb +132 -0
- data/spec/migrations/23_pact_versions_spec.rb +2 -2
- data/spec/migrations/50_create_latest_matrix_spec.rb +84 -16
- data/spec/migrations/change_migration_strategy_spec.rb +1 -1
- data/spec/service_consumers/pact_helper.rb +4 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/support/migration_helpers.rb +1 -1
- data/spec/support/rspec_match_hash.rb +6 -2
- data/spec/support/shared_examples_for_responses.rb +1 -1
- data/spec/support/test_data_builder.rb +61 -11
- metadata +57 -6
@@ -10,41 +10,10 @@ module PactBroker
|
|
10
10
|
let(:td) { TestDataBuilder.new }
|
11
11
|
let(:tags) { ['prod', 'production'] }
|
12
12
|
let(:options) { { tags: tags } }
|
13
|
+
let(:rows) { subject.find_index_items(options) }
|
13
14
|
|
14
15
|
subject{ Service }
|
15
16
|
|
16
|
-
describe ".find_index_items" do
|
17
|
-
let(:consumer) { instance_double("PactBroker::Domain::Pacticipant")}
|
18
|
-
let(:provider) { instance_double("PactBroker::Domain::Pacticipant")}
|
19
|
-
let(:pact) { instance_double("PactBroker::Domain::Pact", id: 1, consumer: consumer, provider: provider, consumer_name: 'foo', provider_name: 'bar', consumer_version_tag_names: [])}
|
20
|
-
let(:verification) { instance_double("PactBroker::Domain::Verification")}
|
21
|
-
let(:pacts) { [pact]}
|
22
|
-
let(:webhooks) { [instance_double("PactBroker::Domain::Webhook")]}
|
23
|
-
let(:triggered_webhooks) { [instance_double("PactBroker::Webhooks::TriggeredWebhook")] }
|
24
|
-
|
25
|
-
before do
|
26
|
-
allow_any_instance_of(PactBroker::Pacts::Repository).to receive(:find_latest_pacts).and_return(pacts)
|
27
|
-
allow_any_instance_of(PactBroker::Pacts::Repository).to receive(:find_latest_pact).and_return(pact)
|
28
|
-
allow(PactBroker::Verifications::Service).to receive(:find_latest_verification_for).and_return(verification)
|
29
|
-
allow(PactBroker::Webhooks::Service).to receive(:find_by_consumer_and_provider).and_return(webhooks)
|
30
|
-
allow(PactBroker::Webhooks::Service).to receive(:find_latest_triggered_webhooks).and_return(triggered_webhooks)
|
31
|
-
end
|
32
|
-
|
33
|
-
it "retrieves the webhooks for the pact" do
|
34
|
-
expect(PactBroker::Webhooks::Service).to receive(:find_by_consumer_and_provider).with(consumer, provider)
|
35
|
-
subject.find_index_items(options)
|
36
|
-
end
|
37
|
-
|
38
|
-
it "retrieves the latest verification for the pact" do
|
39
|
-
expect(PactBroker::Verifications::Service).to receive(:find_latest_verification_for).with(consumer, provider)
|
40
|
-
subject.find_index_items(options)
|
41
|
-
end
|
42
|
-
|
43
|
-
it "returns a list of relationships" do
|
44
|
-
expect(subject.find_index_items(options)).to eq([PactBroker::Domain::IndexItem.create(consumer, provider, pact, true, verification, webhooks)])
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
17
|
describe "find_relationships integration test" do
|
49
18
|
context "when a prod pact exists and is not the latest version" do
|
50
19
|
before do
|
@@ -56,6 +25,7 @@ module PactBroker
|
|
56
25
|
.create_consumer_version_tag("also-ignored")
|
57
26
|
.create_pact
|
58
27
|
.create_verification(provider_version: "2.1.0")
|
28
|
+
.use_provider_version("2.1.0")
|
59
29
|
end
|
60
30
|
|
61
31
|
let(:rows) { subject.find_index_items(options) }
|
@@ -125,6 +95,150 @@ module PactBroker
|
|
125
95
|
expect(rows.first.latest_verification.provider_version_number).to eq '2.0.0'
|
126
96
|
end
|
127
97
|
end
|
98
|
+
|
99
|
+
context "when the verification is the latest for a given tag" do
|
100
|
+
before do
|
101
|
+
td.create_pact_with_hierarchy("Foo", "1", "Bar")
|
102
|
+
.create_verification(provider_version: "1.0.0", tag_names: ['dev', 'prod'])
|
103
|
+
.create_verification(provider_version: "2.0.0", number: 2, tag_names: ['dev'])
|
104
|
+
end
|
105
|
+
|
106
|
+
let(:rows) { subject.find_index_items(options) }
|
107
|
+
let(:options) { { tags: true } }
|
108
|
+
|
109
|
+
it "includes the names of the tags for which the verification is the latest of that tag" do
|
110
|
+
expect(rows.first.provider_version_number).to eq "2.0.0"
|
111
|
+
expect(rows.first.latest_verification_latest_tags.collect(&:name)).to eq ['dev']
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
context "when there are multiple verifications for the latest consumer version" do
|
116
|
+
|
117
|
+
context "with no tags" do
|
118
|
+
before do
|
119
|
+
td.create_pact_with_hierarchy("Foo", "1", "Bar")
|
120
|
+
.create_verification(provider_version: "1.0.0")
|
121
|
+
.create_verification(provider_version: "2.0.0", number: 2)
|
122
|
+
end
|
123
|
+
|
124
|
+
let(:options) { {} }
|
125
|
+
|
126
|
+
it "only returns the row for the latest provider version" do
|
127
|
+
expect(rows.count).to eq 1
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
context "with tags=true" do
|
132
|
+
before do
|
133
|
+
td.create_pact_with_hierarchy("Foo", "1", "Bar")
|
134
|
+
.create_consumer_version("2")
|
135
|
+
.create_consumer_version_tag("prod")
|
136
|
+
.create_consumer_version_tag("master")
|
137
|
+
.create_pact
|
138
|
+
.revise_pact
|
139
|
+
.create_verification(provider_version: "1.0.0")
|
140
|
+
.create_verification(provider_version: "2.0.0", number: 2)
|
141
|
+
end
|
142
|
+
|
143
|
+
let(:options) { {tags: true} }
|
144
|
+
|
145
|
+
it "only returns the row for the latest provider version" do
|
146
|
+
expect(rows.size).to eq 1
|
147
|
+
expect(rows.first.tag_names.sort).to eq ["master","prod"]
|
148
|
+
expect(rows.first.provider_version_number).to eq "2.0.0"
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
context "with tags=true" do
|
153
|
+
before do
|
154
|
+
td.create_pact_with_hierarchy("Foo", "1.0.0", "Bar")
|
155
|
+
.create_verification(provider_version: "4.5.6")
|
156
|
+
.create_consumer_version("2.0.0")
|
157
|
+
.create_consumer_version_tag("dev")
|
158
|
+
.create_pact
|
159
|
+
.revise_pact
|
160
|
+
.create_consumer_version("2.1.0")
|
161
|
+
.create_consumer_version_tag("prod")
|
162
|
+
.create_pact
|
163
|
+
.revise_pact
|
164
|
+
.create_verification(provider_version: "4.5.6", number: 1)
|
165
|
+
.create_verification(provider_version: "4.5.7", number: 2)
|
166
|
+
.create_verification(provider_version: "4.5.8", number: 3)
|
167
|
+
.create_verification(provider_version: "4.5.9", number: 4)
|
168
|
+
.create_provider("Wiffle")
|
169
|
+
.create_pact
|
170
|
+
end
|
171
|
+
|
172
|
+
let(:options) { {tags: true} }
|
173
|
+
|
174
|
+
it "returns a row for each of the head pacts" do
|
175
|
+
expect(rows.size).to eq 3
|
176
|
+
|
177
|
+
expect(rows[0].latest?).to be true
|
178
|
+
expect(rows[0].provider_name).to eq "Bar"
|
179
|
+
expect(rows[0].tag_names).to eq ["prod"]
|
180
|
+
expect(rows[0].provider_version_number).to eq "4.5.9"
|
181
|
+
|
182
|
+
expect(rows[2].latest?).to be false
|
183
|
+
expect(rows[2].provider_name).to eq "Bar"
|
184
|
+
expect(rows[2].tag_names).to eq ["dev"]
|
185
|
+
|
186
|
+
expect(rows[1].latest?).to be true
|
187
|
+
expect(rows[1].provider_name).to eq "Wiffle"
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
context "when a pact with a tag has been verified, and then a new changed version has been published with the same tag" do
|
193
|
+
before do
|
194
|
+
td.create_pact_with_hierarchy("Foo", "1", "Bar")
|
195
|
+
.create_consumer_version_tag("feat-x")
|
196
|
+
.comment("latest verification for feat-x tag")
|
197
|
+
.create_verification(provider_version: "1")
|
198
|
+
.comment("latest feat-x version")
|
199
|
+
.create_consumer_version("2")
|
200
|
+
.create_consumer_version_tag("feat-x")
|
201
|
+
.comment("latest overall version")
|
202
|
+
.create_consumer_version("3")
|
203
|
+
.create_pact
|
204
|
+
.comment("latest overall verification")
|
205
|
+
.create_verification(provider_version: "2")
|
206
|
+
|
207
|
+
end
|
208
|
+
|
209
|
+
let(:options) { { tags: true } }
|
210
|
+
|
211
|
+
it "returns the latest feat-x verification for the latest feat-x pact" do
|
212
|
+
expect(rows.last.tag_names).to eq ["feat-x"]
|
213
|
+
expect(rows.last.provider_version_number).to eq "1"
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
context "when a pact with two tags has been verified, and then a new changed version has been published with two tags" do
|
218
|
+
before do
|
219
|
+
td.create_pact_with_hierarchy("Foo", "1", "Bar")
|
220
|
+
.create_consumer_version_tag("feat-x")
|
221
|
+
.create_verification(provider_version: "1", comment: "latest feat-x verif")
|
222
|
+
.create_consumer_version("2")
|
223
|
+
.create_consumer_version_tag("feat-y")
|
224
|
+
.create_pact
|
225
|
+
.create_verification(provider_version: "2", comment: "latest feat-y verif")
|
226
|
+
.create_consumer_version("3")
|
227
|
+
.create_consumer_version_tag("feat-x")
|
228
|
+
.create_consumer_version_tag("feat-y")
|
229
|
+
.create_pact
|
230
|
+
.create_consumer_version("4")
|
231
|
+
.create_pact
|
232
|
+
end
|
233
|
+
|
234
|
+
let(:options) { { tags: true } }
|
235
|
+
|
236
|
+
it "returns the latest of the feat-x and feat-y verifications" do
|
237
|
+
expect(rows.last.consumer_version_number).to eq "3"
|
238
|
+
expect(rows.last.tag_names.sort).to eq ["feat-x", "feat-y"]
|
239
|
+
expect(rows.last.provider_version_number).to eq "2"
|
240
|
+
end
|
241
|
+
end
|
128
242
|
end
|
129
243
|
end
|
130
244
|
end
|
@@ -41,7 +41,9 @@ module PactBroker
|
|
41
41
|
.create_pact
|
42
42
|
end
|
43
43
|
|
44
|
-
subject { shorten_rows(
|
44
|
+
subject { shorten_rows(rows) }
|
45
|
+
let(:rows) { Repository.new.find(selectors, options) }
|
46
|
+
|
45
47
|
|
46
48
|
let(:options) { { latestby: latestby } }
|
47
49
|
let(:latestby) { nil }
|
@@ -248,6 +250,47 @@ module PactBroker
|
|
248
250
|
end
|
249
251
|
end
|
250
252
|
|
253
|
+
describe "find" do
|
254
|
+
describe "when a pact for a particular consumer version is published, then re-published with different content, then published again with the original content" do
|
255
|
+
before do
|
256
|
+
first_pact = td.create_pact_with_hierarchy("billy", "1", "bobby").and_return(:pact)
|
257
|
+
td.create_verification(provider_version: "1")
|
258
|
+
.revise_pact
|
259
|
+
.revise_pact(first_pact.json_content)
|
260
|
+
end
|
261
|
+
|
262
|
+
let(:selectors) { build_selectors('billy' => nil, 'bobby' => nil) }
|
263
|
+
|
264
|
+
subject { Repository.new.find(selectors, options) }
|
265
|
+
|
266
|
+
context "when latestby: cvpv" do
|
267
|
+
let(:options) { { latestby: 'cvpv' } }
|
268
|
+
|
269
|
+
it "only includes the row for the latest revision" do
|
270
|
+
expect(subject.size).to eq 1
|
271
|
+
expect(subject).to contain_hash(pact_revision_number: 3)
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
context "when latestby: cvp" do
|
276
|
+
let(:options) { { latestby: 'cvp' } }
|
277
|
+
|
278
|
+
it "only includes the row for the latest revision" do
|
279
|
+
expect(subject.size).to eq 1
|
280
|
+
expect(subject).to contain_hash(pact_revision_number: 3)
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
context "when latestby: nil" do
|
285
|
+
let(:options) { {} }
|
286
|
+
|
287
|
+
it "includes all the rows" do
|
288
|
+
expect(subject.size).to eq 3
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
251
294
|
describe "find" do
|
252
295
|
let(:options) { {} }
|
253
296
|
|
@@ -510,6 +553,10 @@ module PactBroker
|
|
510
553
|
expect(subject).to include_hash_matching provider_version_number: "2.0.0"
|
511
554
|
expect(subject.size).to eq 1
|
512
555
|
end
|
556
|
+
|
557
|
+
it "returns the tag information" do
|
558
|
+
expect(subject.first[:provider_version_tags]).to include_hash_matching name: 'prod', latest: 1
|
559
|
+
end
|
513
560
|
end
|
514
561
|
|
515
562
|
context "when the latest version is specified for a provider without a tag" do
|
@@ -3,6 +3,65 @@ require 'pact_broker/matrix/row'
|
|
3
3
|
module PactBroker
|
4
4
|
module Matrix
|
5
5
|
describe Row do
|
6
|
+
describe "refresh", migration: true do
|
7
|
+
before do
|
8
|
+
PactBroker::Database.migrate
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:td) { TestDataBuilder.new(auto_refresh_matrix: false) }
|
12
|
+
|
13
|
+
before do
|
14
|
+
td.create_pact_with_hierarchy("Foo", "1", "Bar")
|
15
|
+
end
|
16
|
+
|
17
|
+
context "with only a consumer_name" do
|
18
|
+
subject { Row.refresh(consumer_name: "Foo") }
|
19
|
+
|
20
|
+
it "refreshes the data for the consumer" do
|
21
|
+
subject
|
22
|
+
expect(Row.all.collect(&:values)).to contain_hash(provider_name: "Bar", consumer_name: "Foo")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "with only a provider_name" do
|
27
|
+
subject { Row.refresh(provider_name: "Bar") }
|
28
|
+
|
29
|
+
it "refreshes the data for the provider" do
|
30
|
+
subject
|
31
|
+
expect(Row.all.collect(&:values)).to contain_hash(provider_name: "Bar", consumer_name: "Foo")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "with both consumer_name and provider_name" do
|
36
|
+
subject { Row.refresh(provider_name: "Bar", consumer_name: "Foo") }
|
37
|
+
|
38
|
+
it "refreshes the data for the consumer and provider" do
|
39
|
+
subject
|
40
|
+
expect(Row.all.collect(&:values)).to contain_hash(provider_name: "Bar", consumer_name: "Foo")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "when there was existing data" do
|
45
|
+
it "deletes the existing data before inserting the new data" do
|
46
|
+
Row.refresh(provider_name: "Bar", consumer_name: "Foo")
|
47
|
+
expect(Row.count).to eq 1
|
48
|
+
td.create_consumer_version("2")
|
49
|
+
.create_pact
|
50
|
+
Row.refresh(provider_name: "Bar", consumer_name: "Foo")
|
51
|
+
expect(Row.count).to eq 2
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "with a pacticipant_name" do
|
56
|
+
subject { Row.refresh(pacticipant_name: "Bar") }
|
57
|
+
|
58
|
+
it "refreshes the data for both consumer and provider roles" do
|
59
|
+
subject
|
60
|
+
expect(Row.all.collect(&:values)).to contain_hash(provider_name: "Bar", consumer_name: "Foo")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
6
65
|
describe "<=>" do
|
7
66
|
let(:row_1) do
|
8
67
|
Row.new(
|
@@ -11,8 +11,11 @@ module PactBroker
|
|
11
11
|
let(:provider) { instance_double("PactBroker::Domain::Pacticipant", name: 'Provider Name')}
|
12
12
|
let(:latest_pact) { instance_double("PactBroker::Domain::Pact") }
|
13
13
|
let(:latest_verification) { instance_double("PactBroker::Domain::Verification") }
|
14
|
-
let(:domain_relationship) { PactBroker::Domain::IndexItem.new(consumer, provider, latest_pact, latest, latest_verification, [], [], tags)}
|
14
|
+
let(:domain_relationship) { PactBroker::Domain::IndexItem.new(consumer, provider, latest_pact, latest, latest_verification, [], [], tags, latest_verification_latest_tags)}
|
15
15
|
let(:tags) { [] }
|
16
|
+
let(:verification_tag_1) { instance_double("PactBroker::Tags::TagWithLatestFlag", name: 'dev') }
|
17
|
+
let(:verification_tag_2) { instance_double("PactBroker::Tags::TagWithLatestFlag", name: 'prod') }
|
18
|
+
let(:latest_verification_latest_tags) { [verification_tag_1, verification_tag_2] }
|
16
19
|
let(:latest) { true }
|
17
20
|
|
18
21
|
subject { IndexItem.new(domain_relationship) }
|
@@ -111,22 +114,24 @@ module PactBroker
|
|
111
114
|
end
|
112
115
|
end
|
113
116
|
|
114
|
-
describe "
|
115
|
-
context "when the pact is the overall latest
|
116
|
-
its(:
|
117
|
+
describe "latest?" do
|
118
|
+
context "when the pact is the overall latest" do
|
119
|
+
its(:latest?) { is_expected.to be true }
|
117
120
|
end
|
118
121
|
|
119
|
-
context "when the pact is the
|
120
|
-
let(:tags) { ["master", "prod"] }
|
121
|
-
its(:tag_names) { is_expected.to eq " (latest & latest master, prod) " }
|
122
|
-
end
|
123
|
-
|
124
|
-
context "when the pact is not the latest and has tag names" do
|
122
|
+
context "when the pact is not the latest" do
|
125
123
|
let(:latest) { false }
|
126
|
-
|
127
|
-
its(:tag_names) { is_expected.to eq " (latest master, prod) " }
|
124
|
+
its(:latest?) { is_expected.to be false }
|
128
125
|
end
|
126
|
+
end
|
127
|
+
|
128
|
+
describe "consumer_version_latest_tag_names" do
|
129
|
+
let(:tags) { ["master", "prod"] }
|
130
|
+
its(:consumer_version_latest_tag_names) { is_expected.to eq ["master", "prod"] }
|
131
|
+
end
|
129
132
|
|
133
|
+
describe "provider_version_latest_tag_names" do
|
134
|
+
its(:provider_version_latest_tag_names) { is_expected.to eq ["dev", "prod"] }
|
130
135
|
end
|
131
136
|
|
132
137
|
describe "<=>" do
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'pact_broker/versions/abbreviate_number'
|
2
|
+
|
3
|
+
module PactBroker
|
4
|
+
module Versions
|
5
|
+
describe AbbreviateNumber do
|
6
|
+
describe "#call" do
|
7
|
+
TEST_CASES = [
|
8
|
+
['202326572516dea6998a7f311fcaa161c0768fc2', '2023265'],
|
9
|
+
['1.2.3+areallyreallyreallylongexplanation', '1.2.3+areallyreallyreallylongexplanation'],
|
10
|
+
['2516dea6998a7f', '2516dea6998a7f'],
|
11
|
+
['1.2.3+202326572516dea6998a7f311fcaa161c0768fc2', '1.2.3+2023265']
|
12
|
+
]
|
13
|
+
|
14
|
+
TEST_CASES.each do |(input, output)|
|
15
|
+
it "shortens #{input} to #{output}" do
|
16
|
+
expect(AbbreviateNumber.call(input)).to eq output
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
describe "latest tagged matrix", migration: true do
|
2
|
+
let(:td) { TestDataBuilder.new }
|
3
|
+
|
4
|
+
before do
|
5
|
+
PactBroker::Database.migrate
|
6
|
+
end
|
7
|
+
|
8
|
+
subject { database[:head_matrix].all }
|
9
|
+
|
10
|
+
context "with a single consumer version tag on the latest version" do
|
11
|
+
before do
|
12
|
+
td.create_pact_with_hierarchy("Foo", "1", "Bar")
|
13
|
+
.create_consumer_version_tag("prod")
|
14
|
+
.create_consumer_version("2")
|
15
|
+
.create_consumer_version_tag("prod")
|
16
|
+
.create_pact
|
17
|
+
.revise_pact
|
18
|
+
end
|
19
|
+
|
20
|
+
context "without a verification" do
|
21
|
+
it "returns a line with no tag and a line with a tag" do
|
22
|
+
expect(subject).to contain_hash(
|
23
|
+
consumer_version_tag_name: nil,
|
24
|
+
consumer_version_number: "2"
|
25
|
+
)
|
26
|
+
expect(subject).to contain_hash(
|
27
|
+
consumer_version_tag_name: "prod",
|
28
|
+
consumer_version_number: "2"
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "with a verification" do
|
34
|
+
before do
|
35
|
+
td.create_verification(provider_version: "3")
|
36
|
+
end
|
37
|
+
it "returns the verification details" do
|
38
|
+
expect(subject).to contain_hash(
|
39
|
+
consumer_version_tag_name: nil,
|
40
|
+
consumer_version_number: "2",
|
41
|
+
provider_version_number: "3"
|
42
|
+
)
|
43
|
+
expect(subject).to contain_hash(
|
44
|
+
consumer_version_tag_name: "prod",
|
45
|
+
consumer_version_number: "2",
|
46
|
+
provider_version_number: "3"
|
47
|
+
)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
context "with two tags on the latest version" do
|
52
|
+
before do
|
53
|
+
td.create_pact_with_hierarchy("Foo", "1", "Bar")
|
54
|
+
.create_consumer_version_tag("prod")
|
55
|
+
.create_consumer_version_tag("master")
|
56
|
+
.create_consumer_version("2")
|
57
|
+
.create_consumer_version_tag("prod")
|
58
|
+
.create_consumer_version_tag("master")
|
59
|
+
.create_pact
|
60
|
+
.revise_pact
|
61
|
+
end
|
62
|
+
|
63
|
+
it "returns a line with no tag, and a line for each tag" do
|
64
|
+
expect(subject).to contain_hash(
|
65
|
+
consumer_version_tag_name: nil,
|
66
|
+
consumer_version_number: "2"
|
67
|
+
)
|
68
|
+
expect(subject).to contain_hash(
|
69
|
+
consumer_version_tag_name: "prod",
|
70
|
+
consumer_version_number: "2"
|
71
|
+
)
|
72
|
+
|
73
|
+
expect(subject).to contain_hash(
|
74
|
+
consumer_version_tag_name: "master",
|
75
|
+
consumer_version_number: "2"
|
76
|
+
)
|
77
|
+
end
|
78
|
+
|
79
|
+
context "with a verification" do
|
80
|
+
before do
|
81
|
+
td.create_verification(provider_version: "3")
|
82
|
+
end
|
83
|
+
it "returns the verification details" do
|
84
|
+
expect(subject).to contain_hash(
|
85
|
+
consumer_version_tag_name: nil,
|
86
|
+
consumer_version_number: "2",
|
87
|
+
provider_version_number: "3"
|
88
|
+
)
|
89
|
+
expect(subject).to contain_hash(
|
90
|
+
consumer_version_tag_name: "prod",
|
91
|
+
consumer_version_number: "2",
|
92
|
+
provider_version_number: "3"
|
93
|
+
)
|
94
|
+
|
95
|
+
expect(subject).to contain_hash(
|
96
|
+
consumer_version_tag_name: "master",
|
97
|
+
consumer_version_number: "2",
|
98
|
+
provider_version_number: "3"
|
99
|
+
)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
context "with different versions for overall latest, and two other tags" do
|
104
|
+
before do
|
105
|
+
td.create_pact_with_hierarchy("Foo", "1", "Bar")
|
106
|
+
.create_consumer_version_tag("prod")
|
107
|
+
.create_consumer_version_tag("master")
|
108
|
+
.create_consumer_version("2")
|
109
|
+
.create_consumer_version_tag("master")
|
110
|
+
.create_pact
|
111
|
+
.revise_pact
|
112
|
+
.create_consumer_version("3")
|
113
|
+
.create_pact
|
114
|
+
end
|
115
|
+
|
116
|
+
it "returns a line for each" do
|
117
|
+
expect(subject).to contain_hash(
|
118
|
+
consumer_version_tag_name: nil,
|
119
|
+
consumer_version_number: "3"
|
120
|
+
)
|
121
|
+
expect(subject).to contain_hash(
|
122
|
+
consumer_version_tag_name: "prod",
|
123
|
+
consumer_version_number: "1"
|
124
|
+
)
|
125
|
+
|
126
|
+
expect(subject).to contain_hash(
|
127
|
+
consumer_version_tag_name: "master",
|
128
|
+
consumer_version_number: "2"
|
129
|
+
)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|