pact_broker 2.7.0.beta.1 → 2.7.0.beta.2
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/.gitignore +1 -0
- data/CHANGELOG.md +30 -4
- data/db/migrations/{01_create_pacticipant_table.rb → 000001_create_pacticipant_table.rb} +0 -0
- data/db/migrations/{02_create_versions_table.rb → 000002_create_versions_table.rb} +0 -0
- data/db/migrations/{03_create_pacts_table.rb → 000003_create_pacts_table.rb} +0 -0
- data/db/migrations/{04_create_tags_table.rb → 000004_create_tags_table.rb} +0 -0
- data/db/migrations/{05_add_order_column_to_version.rb → 000005_add_order_column_to_version.rb} +0 -0
- data/db/migrations/{06_make_version_foreign_key_mandatory.rb → 000006_make_version_foreign_key_mandatory.rb} +0 -0
- data/db/migrations/{07_increase_json_content_length.rb → 000007_increase_json_content_length.rb} +0 -0
- data/db/migrations/{08_create_latest_pact_view.rb → 000008_create_latest_pact_view.rb} +0 -0
- data/db/migrations/{09_add_timestamps.rb → 000009_add_timestamps.rb} +0 -0
- data/db/migrations/{10_populate_timestamps.rb → 000010_populate_timestamps.rb} +0 -0
- data/db/migrations/{11_made_timestamps_mandatory.rb → 000011_made_timestamps_mandatory.rb} +0 -0
- data/db/migrations/{12_create_webhooks_table.rb → 000012_create_webhooks_table.rb} +0 -0
- data/db/migrations/{13_add_columns_to_webhooks.rb → 000013_add_columns_to_webhooks.rb} +0 -0
- data/db/migrations/{14_add_timestamps_to_pact_views.rb → 000014_add_timestamps_to_pact_views.rb} +0 -0
- data/db/migrations/{15_create_pact_version_content.rb → 000015_create_pact_version_content.rb} +0 -0
- data/db/migrations/{16_add_pact_content_foreign_key_to_pacts.rb → 000016_add_pact_content_foreign_key_to_pacts.rb} +0 -0
- data/db/migrations/{17_migrate_json_content_to_pact_version_content_table.rb → 000017_migrate_json_content_to_pact_version_content_table.rb} +0 -0
- data/db/migrations/{18_drop_json_content_column_from_pacts.rb → 000018_drop_json_content_column_from_pacts.rb} +0 -0
- data/db/migrations/{19_make_pact_version_content_sha_not_nullable.rb → 000019_make_pact_version_content_sha_not_nullable.rb} +0 -0
- data/db/migrations/{20_add_pact_version_content_sha_to_all_pacts_view.rb → 000020_add_pact_version_content_sha_to_all_pacts_view.rb} +0 -0
- data/db/migrations/{21_recreate_latest_pacts_view.rb → 000021_recreate_latest_pacts_view.rb} +0 -0
- data/db/migrations/{22_create_latest_tagged_pacts_view.rb → 000022_create_latest_tagged_pacts_view.rb} +0 -0
- data/db/migrations/{23_create_pact_versions_table.rb → 000023_create_pact_versions_table.rb} +0 -0
- data/db/migrations/{24_populate_pact_versions.rb → 000024_populate_pact_versions.rb} +0 -0
- data/db/migrations/{25_make_pv_pacticipants_mandatory.rb → 000025_make_pv_pacticipants_mandatory.rb} +0 -0
- data/db/migrations/{26_create_pact_publications.rb → 000026_create_pact_publications.rb} +0 -0
- data/db/migrations/{27_populate_pact_publications.rb → 000027_populate_pact_publications.rb} +0 -0
- data/db/migrations/{28_create_all_pact_publications.rb → 000028_create_all_pact_publications.rb} +0 -0
- data/db/migrations/{29_create_latest_tagged_pact_publications.rb → 000029_create_latest_tagged_pact_publications.rb} +0 -0
- data/db/migrations/{30_drop_old_tables_and_views.rb → 000030_drop_old_tables_and_views.rb} +0 -0
- data/db/migrations/{31_create_verifications.rb → 000031_create_verifications.rb} +0 -0
- data/db/migrations/{32_create_latest_verifications.rb → 000032_create_latest_verifications.rb} +0 -0
- data/db/migrations/{33_create_config_table.rb → 000033_create_config_table.rb} +0 -0
- data/db/migrations/{34_create_index_on_consumer_version_order.rb → 000034_create_index_on_consumer_version_order.rb} +0 -0
- data/db/migrations/{35_create_index_on_names.rb → 000035_create_index_on_names.rb} +0 -0
- data/db/migrations/{36_create_webhook_execution.rb → 000036_create_webhook_execution.rb} +0 -0
- data/db/migrations/{37_create_labels_table.rb → 000037_create_labels_table.rb} +0 -0
- data/db/migrations/{38_create_triggered_webhooks_table.rb → 000038_create_triggered_webhooks_table.rb} +0 -0
- data/db/migrations/{39_add_triggered_webhooks_fk_to_execution.rb → 000039_add_triggered_webhooks_fk_to_execution.rb} +0 -0
- data/db/migrations/{40_create_latest_triggered_webhooks_view.rb → 000040_create_latest_triggered_webhooks_view.rb} +0 -0
- data/db/migrations/{41_migrate_execution_data.rb → 000041_migrate_execution_data.rb} +0 -0
- data/db/migrations/{42_delete_orphan_webhook_data.rb → 000042_delete_orphan_webhook_data.rb} +0 -0
- data/db/migrations/{43_add_provider_version_to_verification.rb → 000043_add_provider_version_to_verification.rb} +0 -0
- data/db/migrations/{44_populate_verifications_provider_version_id.rb → 000044_populate_verifications_provider_version_id.rb} +0 -0
- data/db/migrations/{45_set_verification_provider_number_nullable.rb → 000045_set_verification_provider_number_nullable.rb} +0 -0
- data/db/migrations/{46_recreate_latest_verifications.rb → 000046_recreate_latest_verifications.rb} +0 -0
- data/db/migrations/{47_create_all_verifications.rb → 000047_create_all_verifications.rb} +4 -0
- data/db/pact_broker_database.sqlite3 +0 -0
- data/db/test/backwards_compatibility/Appraisals +8 -0
- data/db/test/backwards_compatibility/Rakefile +23 -6
- data/db/test/backwards_compatibility/gemfiles/1.18.0.gemfile.lock +20 -19
- data/db/test/backwards_compatibility/gemfiles/2.0.0.gemfile.lock +20 -19
- data/db/test/backwards_compatibility/gemfiles/2.1.0.gemfile.lock +20 -19
- data/db/test/backwards_compatibility/gemfiles/2.2.0.gemfile.lock +29 -26
- data/db/test/backwards_compatibility/gemfiles/2.3.0.gemfile.lock +29 -26
- data/db/test/backwards_compatibility/gemfiles/2.4.2.gemfile.lock +29 -26
- data/db/test/backwards_compatibility/gemfiles/2.5.1.gemfile +13 -0
- data/db/test/backwards_compatibility/gemfiles/2.5.1.gemfile.lock +199 -0
- data/db/test/backwards_compatibility/gemfiles/2.6.0.gemfile +13 -0
- data/db/test/backwards_compatibility/gemfiles/2.6.0.gemfile.lock +199 -0
- data/db/test/backwards_compatibility/gemfiles/head.gemfile.lock +30 -27
- data/db/test/backwards_compatibility/spec/publish_pact_spec.rb +1 -1
- data/db/test/change_migration_strategy/Rakefile +21 -0
- data/db/test/change_migration_strategy/before/Gemfile +6 -0
- data/lib/pact_broker/api/decorators/matrix_decorator.rb +19 -1
- data/lib/pact_broker/api/decorators/matrix_text_decorator.rb +29 -0
- data/lib/pact_broker/api/renderers/html_pact_renderer.rb +1 -1
- data/lib/pact_broker/api/resources/matrix.rb +21 -11
- data/lib/pact_broker/api/resources/matrix_for_consumer_and_provider.rb +2 -2
- data/lib/pact_broker/app.rb +27 -2
- data/lib/pact_broker/db/migrate.rb +1 -1
- data/lib/pact_broker/db/version.rb +4 -5
- data/lib/pact_broker/db.rb +1 -1
- data/lib/pact_broker/domain/relationship.rb +4 -24
- data/lib/pact_broker/matrix/parse_query.rb +22 -0
- data/lib/pact_broker/matrix/repository.rb +57 -26
- data/lib/pact_broker/matrix/service.rb +23 -16
- data/lib/pact_broker/pacticipants/service.rb +5 -21
- data/lib/pact_broker/pacts/pact_publication.rb +0 -4
- data/lib/pact_broker/pacts/repository.rb +1 -1
- data/lib/pact_broker/tags/service.rb +1 -0
- data/lib/pact_broker/ui/controllers/matrix.rb +3 -2
- data/lib/pact_broker/ui/controllers/relationships.rb +2 -2
- data/lib/pact_broker/ui/view_models/matrix_line.rb +38 -5
- data/lib/pact_broker/ui/view_models/relationship.rb +1 -19
- data/lib/pact_broker/ui/views/matrix/show.haml +18 -3
- data/lib/pact_broker/ui/views/relationships/show.haml +2 -2
- data/lib/pact_broker/verifications/repository.rb +0 -3
- data/lib/pact_broker/version.rb +1 -1
- data/lib/rack/hal_browser/redirect.rb +2 -2
- data/lib/rack/pact_broker/configurable_make_it_later.rb +24 -0
- data/lib/rack/pact_broker/no_auth.rb +13 -0
- data/pact_broker.gemspec +1 -0
- data/script/seed-matrix.rb +71 -0
- data/script/seed.rb +0 -5
- data/spec/features/get_matrix_spec.rb +4 -1
- data/spec/lib/pact_broker/api/decorators/matrix_decorator_spec.rb +41 -7
- data/spec/lib/pact_broker/api/resources/matrix_spec.rb +6 -2
- data/spec/lib/pact_broker/app_spec.rb +69 -0
- data/spec/lib/pact_broker/domain/relationship_spec.rb +1 -1
- data/spec/lib/pact_broker/matrix/parse_query_spec.rb +79 -0
- data/spec/lib/pact_broker/matrix/repository_spec.rb +244 -12
- data/spec/lib/pact_broker/matrix/service_spec.rb +39 -9
- data/spec/lib/pact_broker/pacticipants/service_spec.rb +4 -78
- data/spec/lib/pact_broker/pacts/repository_spec.rb +14 -16
- data/spec/lib/pact_broker/ui/view_models/relationship_spec.rb +5 -4
- data/spec/migrations/change_migration_strategy_spec.rb +86 -0
- data/spec/service_consumers/provider_states_for_pact_broker_client.rb +34 -0
- data/spec/support/test_data_builder.rb +6 -0
- data/tasks/database.rb +1 -1
- metadata +78 -52
- data/lib/pact_broker/ui/views/relationships/show-prod-tags.haml +0 -83
- data/spec/lib/pact_broker/pacts/pact_publication_spec.rb +0 -35
|
@@ -3,7 +3,225 @@ require 'pact_broker/matrix/repository'
|
|
|
3
3
|
module PactBroker
|
|
4
4
|
module Matrix
|
|
5
5
|
describe Repository do
|
|
6
|
-
|
|
6
|
+
let(:td) { TestDataBuilder.new}
|
|
7
|
+
|
|
8
|
+
def build_selectors(hash)
|
|
9
|
+
hash.collect do | key, value |
|
|
10
|
+
{ pacticipant_name: key, pacticipant_version_number: value }
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe "find" do
|
|
15
|
+
context "when the provider version resource exists but there is no verification for that version" do
|
|
16
|
+
before do
|
|
17
|
+
# A/1.2.3 -> B
|
|
18
|
+
# B/2.0.0
|
|
19
|
+
# C/3.0.0
|
|
20
|
+
td.create_pact_with_hierarchy("A", "1.2.3", "B")
|
|
21
|
+
.use_provider("B")
|
|
22
|
+
.create_version("2.0.0")
|
|
23
|
+
.create_provider("C")
|
|
24
|
+
.create_version("3.0.0")
|
|
25
|
+
.create_pact
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
subject { Repository.new.find build_selectors("A" => "1.2.3", "B" => "2.0.0", "C" => "3.0.0") }
|
|
29
|
+
|
|
30
|
+
it "returns a row for each pact" do
|
|
31
|
+
expect(subject.size).to eq 2
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "returns an row with a blank provider_version_number" do
|
|
35
|
+
expect(subject.first).to include consumer_name: "A",
|
|
36
|
+
provider_name: "B",
|
|
37
|
+
consumer_version_number: "1.2.3",
|
|
38
|
+
provider_version_number: nil
|
|
39
|
+
|
|
40
|
+
expect(subject.last).to include consumer_name: "A",
|
|
41
|
+
provider_name: "C",
|
|
42
|
+
consumer_version_number: "1.2.3",
|
|
43
|
+
provider_version_number: nil
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
context "when only 2 version selectors are specified" do
|
|
47
|
+
let(:selectors) { build_selectors("A" => "1.2.3", "B" => "2.0.0") }
|
|
48
|
+
|
|
49
|
+
subject { Repository.new.find(selectors) }
|
|
50
|
+
|
|
51
|
+
it "only returns 1 row" do
|
|
52
|
+
expect(subject.size).to eq 1
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
context "when only one pacticipant/version is specified and it is a consumer" do
|
|
58
|
+
before do
|
|
59
|
+
td.create_pact_with_hierarchy("A", "1.2.3", "B")
|
|
60
|
+
.create_verification(provider_version: "4.5.6")
|
|
61
|
+
.create_provider("D")
|
|
62
|
+
.create_pact
|
|
63
|
+
.create_verification(provider_version: "6.7.8")
|
|
64
|
+
.create_consumer_version("5.5.5")
|
|
65
|
+
.create_pact
|
|
66
|
+
.create_verification(provider_version: "4.5.6")
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
subject { Repository.new.find build_selectors("A" => "1.2.3") }
|
|
70
|
+
|
|
71
|
+
it "returns a row for each verification for that version" do
|
|
72
|
+
expect(subject.size).to eq 2
|
|
73
|
+
expect(subject.collect{|r| r[:consumer_version_number]}.sort).to eq ["1.2.3", "1.2.3"]
|
|
74
|
+
expect(subject.collect{|r| r[:provider_version_number]}.sort).to eq ["4.5.6", "6.7.8"]
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
context "when only one pacticipant name is specified and it is a consumer" do
|
|
79
|
+
before do
|
|
80
|
+
td.create_pact_with_hierarchy("A", "1.2.3", "B")
|
|
81
|
+
.create_verification(provider_version: "4.5.6")
|
|
82
|
+
.create_provider("D")
|
|
83
|
+
.create_pact
|
|
84
|
+
.create_pact_with_hierarchy("X", "1.2.3", "Y")
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
subject { Repository.new.find build_selectors("A" => nil) }
|
|
88
|
+
|
|
89
|
+
it "returns a row for each verification for the pacticipant" do
|
|
90
|
+
expect(subject.collect{|r| r[:consumer_name]}.uniq).to eq ["A"]
|
|
91
|
+
provider_version_numbers = subject.collect{|r| r[:provider_version_number]}
|
|
92
|
+
expect(provider_version_numbers).to include nil
|
|
93
|
+
expect(provider_version_numbers).to include "4.5.6"
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
context "when only one pacticipant/version is specified and it is a provider" do
|
|
98
|
+
before do
|
|
99
|
+
td.create_pact_with_hierarchy("A", "1.2.3", "B")
|
|
100
|
+
.create_verification(provider_version: "4.5.6")
|
|
101
|
+
.create_consumer("D")
|
|
102
|
+
.create_consumer_version("3.4.5")
|
|
103
|
+
.create_pact
|
|
104
|
+
.create_verification(provider_version: "4.5.6")
|
|
105
|
+
.create_verification(provider_version: "6.7.8", number: 2)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
subject { Repository.new.find build_selectors("B" => "4.5.6") }
|
|
109
|
+
|
|
110
|
+
it "returns a row for each verification for that version" do
|
|
111
|
+
expect(subject.size).to eq 2
|
|
112
|
+
expect(subject.collect{|r| r[:consumer_version_number]}.sort).to eq ["1.2.3", "3.4.5"]
|
|
113
|
+
expect(subject.collect{|r| r[:provider_version_number]}.sort).to eq ["4.5.6", "4.5.6"]
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
context "when only one pacticipant name is specified and it is a provider" do
|
|
118
|
+
before do
|
|
119
|
+
td.create_pact_with_hierarchy("A", "1.2.3", "B")
|
|
120
|
+
.create_verification(provider_version: "4.5.6")
|
|
121
|
+
.create_consumer("D")
|
|
122
|
+
.create_consumer_version("3.4.5")
|
|
123
|
+
.create_pact
|
|
124
|
+
.create_verification(provider_version: "4.5.6")
|
|
125
|
+
.create_verification(provider_version: "6.7.8", number: 2)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
subject { Repository.new.find build_selectors("B" => nil) }
|
|
129
|
+
|
|
130
|
+
it "returns a row for each verification for that version" do
|
|
131
|
+
expect(subject.size).to eq 3
|
|
132
|
+
expect(subject.collect{|r| r[:consumer_version_number]}.sort).to eq ["1.2.3", "3.4.5", "3.4.5"]
|
|
133
|
+
expect(subject.collect{|r| r[:provider_version_number]}.sort).to eq ["4.5.6", "4.5.6", "6.7.8"]
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
context "when only one pacticipant/version is specified and it is a consumer and provider" do
|
|
138
|
+
before do
|
|
139
|
+
td.create_pact_with_hierarchy("A", "1", "B")
|
|
140
|
+
.create_verification(provider_version: '1')
|
|
141
|
+
.create_verification(provider_version: '2', number: 2, success: false)
|
|
142
|
+
.create_verification(provider_version: '4', number: 3)
|
|
143
|
+
.create_provider_version("5")
|
|
144
|
+
.use_consumer("B")
|
|
145
|
+
.use_consumer_version("1")
|
|
146
|
+
.create_provider("C")
|
|
147
|
+
.create_pact
|
|
148
|
+
.create_verification(provider_version: '1', success: false)
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
subject { Repository.new.find build_selectors("B" => "1") }
|
|
152
|
+
|
|
153
|
+
it "returns rows where the pacticipant is the consumer and rows where the pacticipant is the provider" do
|
|
154
|
+
# A/1 and B/1
|
|
155
|
+
# B/1 and C/1
|
|
156
|
+
expect(subject.size).to eq 2
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
context "using the success option" do
|
|
161
|
+
before do
|
|
162
|
+
td.create_pact_with_hierarchy("A", "1.2.3", "B")
|
|
163
|
+
.create_verification(provider_version: "1.0.0")
|
|
164
|
+
.create_consumer_version("1.2.4")
|
|
165
|
+
.create_pact
|
|
166
|
+
.create_verification(provider_version: "2.0.0", success: false)
|
|
167
|
+
.create_consumer_version("1.2.5")
|
|
168
|
+
.create_pact
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
let(:selectors) { build_selectors("A" => nil, "B" => nil) }
|
|
172
|
+
|
|
173
|
+
subject { Repository.new.find(selectors, options) }
|
|
174
|
+
|
|
175
|
+
context "when the success option is not set" do
|
|
176
|
+
let(:options) { { } }
|
|
177
|
+
|
|
178
|
+
it "returns all rows specified by the selectors" do
|
|
179
|
+
expect(subject.size).to eq 3
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
context "when the success option is true" do
|
|
184
|
+
let(:options) { { success: [true] } }
|
|
185
|
+
|
|
186
|
+
it "only includes successes" do
|
|
187
|
+
expect(subject.first[:provider_version_number]).to eq "1.0.0"
|
|
188
|
+
expect(subject.size).to eq 1
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
context "when the success option is false" do
|
|
193
|
+
let(:options) { { success: [false] } }
|
|
194
|
+
|
|
195
|
+
it "only includes failures" do
|
|
196
|
+
expect(subject.first[:provider_version_number]).to eq "2.0.0"
|
|
197
|
+
expect(subject.size).to eq 1
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
context "when the success option is nil" do
|
|
202
|
+
let(:options) { { success: [nil] } }
|
|
203
|
+
|
|
204
|
+
it "only includes unverified rows" do
|
|
205
|
+
expect(subject.first[:provider_version_number]).to eq nil
|
|
206
|
+
expect(subject.size).to eq 1
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
context "when multiple success options are specified" do
|
|
211
|
+
let(:options) { { success: [false, nil] } }
|
|
212
|
+
|
|
213
|
+
it "returns all matching rows" do
|
|
214
|
+
# postgres orders differently, and ruby array sort blows up with a nil string
|
|
215
|
+
provider_version_numbers = subject.collect{ |r| r[:provider_version_number]}
|
|
216
|
+
expect(provider_version_numbers).to include nil
|
|
217
|
+
expect(provider_version_numbers).to include "2.0.0"
|
|
218
|
+
expect(provider_version_numbers.size).to eq 2
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
describe "#find_for_consumer_and_provider" do
|
|
7
225
|
before do
|
|
8
226
|
TestDataBuilder.new
|
|
9
227
|
.create_pact_with_hierarchy("Consumer", "1.2.3", "Provider")
|
|
@@ -14,7 +232,7 @@ module PactBroker
|
|
|
14
232
|
.create_pact
|
|
15
233
|
end
|
|
16
234
|
|
|
17
|
-
subject { Repository.new.
|
|
235
|
+
subject { Repository.new.find_for_consumer_and_provider("Consumer", "Provider") }
|
|
18
236
|
|
|
19
237
|
it "returns the latest revision of each pact" do
|
|
20
238
|
expect(subject.count).to eq 2
|
|
@@ -27,7 +245,7 @@ module PactBroker
|
|
|
27
245
|
end
|
|
28
246
|
|
|
29
247
|
it "doesn't matter which way you order the pacticipant names" do
|
|
30
|
-
expect(subject).to eq(Repository.new.
|
|
248
|
+
expect(subject).to eq(Repository.new.find_for_consumer_and_provider "Provider", "Consumer")
|
|
31
249
|
end
|
|
32
250
|
end
|
|
33
251
|
|
|
@@ -52,9 +270,11 @@ module PactBroker
|
|
|
52
270
|
.create_verification(provider_version: '3', number: 2)
|
|
53
271
|
end
|
|
54
272
|
|
|
55
|
-
|
|
273
|
+
let(:selectors){ build_selectors("A" => "1", "B" => "2", "C" => "2") }
|
|
274
|
+
|
|
275
|
+
subject { Repository.new.find_compatible_pacticipant_versions(selectors) }
|
|
56
276
|
|
|
57
|
-
it "returns matrix lines for each compatible version pair" do
|
|
277
|
+
it "returns matrix lines for each compatible version pair (A/1-B/2, B/2-C/2)" do
|
|
58
278
|
expect(subject.first[:consumer_name]).to eq "A"
|
|
59
279
|
expect(subject.first[:consumer_version_number]).to eq "1"
|
|
60
280
|
expect(subject.first[:provider_name]).to eq "B"
|
|
@@ -74,7 +294,8 @@ module PactBroker
|
|
|
74
294
|
end
|
|
75
295
|
|
|
76
296
|
context "when one or more pacticipants does not have a version specified" do
|
|
77
|
-
|
|
297
|
+
let(:selectors){ build_selectors("A" => "1", "B" => "2", "C" => nil) }
|
|
298
|
+
subject { Repository.new.find_compatible_pacticipant_versions(selectors) }
|
|
78
299
|
|
|
79
300
|
it "returns all the rows for that pacticipant" do
|
|
80
301
|
expect(subject[1]).to include(provider_name: "C", provider_version_number: "2")
|
|
@@ -84,10 +305,12 @@ module PactBroker
|
|
|
84
305
|
end
|
|
85
306
|
|
|
86
307
|
context "none of the pacticipants have a version specified" do
|
|
87
|
-
|
|
308
|
+
let(:selectors){ build_selectors("A" => nil, "B" => nil, "C" => nil) }
|
|
309
|
+
|
|
310
|
+
subject { Repository.new.find_compatible_pacticipant_versions(selectors) }
|
|
88
311
|
|
|
89
312
|
it "returns all the rows" do
|
|
90
|
-
expect(subject.size).to eq
|
|
313
|
+
expect(subject.size).to eq 5
|
|
91
314
|
end
|
|
92
315
|
end
|
|
93
316
|
end
|
|
@@ -98,7 +321,10 @@ module PactBroker
|
|
|
98
321
|
.create_verification(provider_version: "1")
|
|
99
322
|
.create_verification(provider_version: "1", number: 2)
|
|
100
323
|
end
|
|
101
|
-
|
|
324
|
+
|
|
325
|
+
let(:selectors){ build_selectors("X" => "1", "Y" => "1") }
|
|
326
|
+
|
|
327
|
+
subject { Repository.new.find_compatible_pacticipant_versions(selectors) }
|
|
102
328
|
|
|
103
329
|
it "returns the last line" do
|
|
104
330
|
expect(subject.size).to eq 1
|
|
@@ -113,7 +339,9 @@ module PactBroker
|
|
|
113
339
|
.create_verification(provider_version: "1", number: 2, success: false)
|
|
114
340
|
end
|
|
115
341
|
|
|
116
|
-
|
|
342
|
+
let(:selectors){ build_selectors("X" => "1", "Y" => "1") }
|
|
343
|
+
|
|
344
|
+
subject { Repository.new.find_compatible_pacticipant_versions(selectors) }
|
|
117
345
|
|
|
118
346
|
it "does not return a matrix line" do
|
|
119
347
|
expect(subject.size).to eq 0
|
|
@@ -127,7 +355,9 @@ module PactBroker
|
|
|
127
355
|
.revise_pact
|
|
128
356
|
end
|
|
129
357
|
|
|
130
|
-
|
|
358
|
+
let(:selectors){ build_selectors("X" => "1", "Y" => "1") }
|
|
359
|
+
|
|
360
|
+
subject { Repository.new.find_compatible_pacticipant_versions(selectors) }
|
|
131
361
|
|
|
132
362
|
it "does not return a matrix line" do
|
|
133
363
|
expect(subject.size).to eq 0
|
|
@@ -141,7 +371,9 @@ module PactBroker
|
|
|
141
371
|
.create_verification(provider_version: '1', success: false)
|
|
142
372
|
end
|
|
143
373
|
|
|
144
|
-
|
|
374
|
+
let(:selectors){ build_selectors("D" => "1", "E" => "1") }
|
|
375
|
+
|
|
376
|
+
subject { Repository.new.find_compatible_pacticipant_versions(selectors) }
|
|
145
377
|
|
|
146
378
|
it "does not return the matrix line" do
|
|
147
379
|
expect(subject.count).to eq 0
|
|
@@ -3,16 +3,17 @@ require 'pact_broker/matrix/service'
|
|
|
3
3
|
module PactBroker
|
|
4
4
|
module Matrix
|
|
5
5
|
describe Service do
|
|
6
|
+
let(:td) { TestDataBuilder.new }
|
|
7
|
+
|
|
6
8
|
describe "validate_selectors" do
|
|
7
|
-
let(:td) { TestDataBuilder.new }
|
|
8
9
|
|
|
9
10
|
subject { Service.validate_selectors(selectors) }
|
|
10
11
|
|
|
11
|
-
context "when
|
|
12
|
-
let(:selectors) { [
|
|
12
|
+
context "when there are no selectors" do
|
|
13
|
+
let(:selectors) { [] }
|
|
13
14
|
|
|
14
15
|
it "returns error messages" do
|
|
15
|
-
expect(subject.first).to eq "
|
|
16
|
+
expect(subject.first).to eq "Please provide 1 or more version selectors."
|
|
16
17
|
end
|
|
17
18
|
end
|
|
18
19
|
|
|
@@ -22,25 +23,54 @@ module PactBroker
|
|
|
22
23
|
.create_version("1")
|
|
23
24
|
.create_pacticipant("Bar")
|
|
24
25
|
.create_version("2")
|
|
25
|
-
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
let(:selectors) { ["Foo
|
|
28
|
+
let(:selectors) { [{ pacticipant_name: "Foo", pacticipant_version_number: "1" }, { pacticipant_name: "Bar", pacticipant_version_number: "1" }] }
|
|
29
29
|
|
|
30
30
|
it "returns error messages" do
|
|
31
|
-
expect(subject).to eq ["No pact or verification found for Bar
|
|
31
|
+
expect(subject).to eq ["No pact or verification found for Bar version 1"]
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
context "when the pacticipant does not exist" do
|
|
36
|
-
let(:selectors) { ["Foo
|
|
36
|
+
let(:selectors) { [{ pacticipant_name: "Foo", pacticipant_version_number: "1" }] }
|
|
37
37
|
|
|
38
38
|
it "returns error messages" do
|
|
39
39
|
expect(subject.first).to eq "Pacticipant 'Foo' not found"
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
|
+
|
|
43
|
+
context "when the pacticipant name is not specified" do
|
|
44
|
+
let(:selectors) { [{ pacticipant_name: nil, pacticipant_version_number: "1" }] }
|
|
45
|
+
|
|
46
|
+
it "returns error messages" do
|
|
47
|
+
expect(subject.first).to eq "Please specify the pacticipant name"
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
context "when the pacticipant version is not specified" do
|
|
52
|
+
before do
|
|
53
|
+
td.create_pacticipant("Foo")
|
|
54
|
+
.create_version("1")
|
|
55
|
+
.create_pacticipant("Bar")
|
|
56
|
+
.create_version("2")
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
let(:selectors) { [ { pacticipant_name: "Foo", pacticipant_version_number: nil }, { pacticipant_name: "Bar", pacticipant_version_number: nil } ] }
|
|
60
|
+
|
|
61
|
+
it "returns no error messages" do
|
|
62
|
+
expect(subject).to eq []
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
context "when the pacticipant name and version are not specified" do
|
|
67
|
+
let(:selectors) { [{ pacticipant_name: nil, pacticipant_version_number: nil }] }
|
|
68
|
+
|
|
69
|
+
it "returns error messages" do
|
|
70
|
+
expect(subject.first).to eq "Please specify the pacticipant name and version"
|
|
71
|
+
end
|
|
72
|
+
end
|
|
42
73
|
end
|
|
43
74
|
end
|
|
44
75
|
end
|
|
45
76
|
end
|
|
46
|
-
|
|
@@ -8,8 +8,6 @@ module PactBroker
|
|
|
8
8
|
module Pacticipants
|
|
9
9
|
describe Service do
|
|
10
10
|
|
|
11
|
-
let(:td) { TestDataBuilder.new }
|
|
12
|
-
|
|
13
11
|
subject{ Service }
|
|
14
12
|
|
|
15
13
|
describe ".messages_for_potential_duplicate_pacticipants" do
|
|
@@ -99,9 +97,10 @@ module PactBroker
|
|
|
99
97
|
end
|
|
100
98
|
|
|
101
99
|
describe ".find_relationships" do
|
|
100
|
+
|
|
102
101
|
let(:consumer) { instance_double("PactBroker::Domain::Pacticipant")}
|
|
103
102
|
let(:provider) { instance_double("PactBroker::Domain::Pacticipant")}
|
|
104
|
-
let(:pact) { instance_double("PactBroker::Domain::Pact",
|
|
103
|
+
let(:pact) { instance_double("PactBroker::Domain::Pact", consumer: consumer, provider: provider)}
|
|
105
104
|
let(:verification) { instance_double("PactBroker::Domain::Verification")}
|
|
106
105
|
let(:pacts) { [pact]}
|
|
107
106
|
let(:webhooks) { [instance_double("PactBroker::Domain::Webhook")]}
|
|
@@ -109,7 +108,6 @@ module PactBroker
|
|
|
109
108
|
|
|
110
109
|
before do
|
|
111
110
|
allow_any_instance_of(PactBroker::Pacts::Repository).to receive(:find_latest_pacts).and_return(pacts)
|
|
112
|
-
allow_any_instance_of(PactBroker::Pacts::Repository).to receive(:find_latest_pact).and_return(pact)
|
|
113
111
|
allow(PactBroker::Verifications::Service).to receive(:find_latest_verification_for).and_return(verification)
|
|
114
112
|
allow(PactBroker::Webhooks::Service).to receive(:find_by_consumer_and_provider).and_return(webhooks)
|
|
115
113
|
allow(PactBroker::Webhooks::Service).to receive(:find_latest_triggered_webhooks).and_return(triggered_webhooks)
|
|
@@ -126,85 +124,13 @@ module PactBroker
|
|
|
126
124
|
end
|
|
127
125
|
|
|
128
126
|
it "returns a list of relationships" do
|
|
129
|
-
expect(subject.find_relationships).to eq([PactBroker::Domain::Relationship.create(consumer, provider, pact,
|
|
127
|
+
expect(subject.find_relationships).to eq([PactBroker::Domain::Relationship.create(consumer, provider, pact, verification, webhooks)])
|
|
130
128
|
end
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
describe "find_relationships integration test" do
|
|
134
|
-
context "when a prod pact exists and is not the latest version" do
|
|
135
|
-
before do
|
|
136
|
-
td.create_pact_with_hierarchy("Foo", "1.2.3", "Bar")
|
|
137
|
-
.create_consumer_version_tag("prod")
|
|
138
|
-
.create_consumer_version_tag("ignored")
|
|
139
|
-
.create_verification(provider_version: "2.0.0")
|
|
140
|
-
.create_consumer_version("1.2.4")
|
|
141
|
-
.create_consumer_version_tag("also-ignored")
|
|
142
|
-
.create_pact
|
|
143
|
-
.create_verification(provider_version: "2.1.0")
|
|
144
|
-
end
|
|
145
129
|
|
|
146
|
-
let(:rows) { subject.find_relationships }
|
|
147
|
-
|
|
148
|
-
it "returns both rows" do
|
|
149
|
-
expect(rows.count).to eq 2
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
it "returns the latest row first" do
|
|
153
|
-
expect(rows.first.consumer_version_number).to eq "1.2.4"
|
|
154
|
-
expect(rows.last.consumer_version_number).to eq "1.2.3"
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
it "designates the first row as the latest row, and the second as not latest" do
|
|
158
|
-
expect(rows.first.latest?).to be true
|
|
159
|
-
expect(rows.last.latest?).to be false
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
it "doesn't return any tag names for the latest row" do
|
|
163
|
-
expect(rows.first.tag_names).to eq []
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
it "includes the prod tag name for the prod row" do
|
|
167
|
-
expect(rows.last.tag_names).to eq ['prod']
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
it "includes the latest overall verification for the latest pact" do
|
|
171
|
-
expect(rows.first.latest_verification.provider_version_number).to eq '2.1.0'
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
it "includes the latest prod verification for the prod pact" do
|
|
175
|
-
expect(rows.last.latest_verification.provider_version_number).to eq '2.0.0'
|
|
176
|
-
end
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
context "when the prod version is the latest version" do
|
|
180
|
-
before do
|
|
181
|
-
td.create_pact_with_hierarchy("Foo", "1.2.3", "Bar")
|
|
182
|
-
.create_consumer_version_tag("prod")
|
|
183
|
-
.create_consumer_version_tag("ignored")
|
|
184
|
-
.create_verification(provider_version: "2.0.0")
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
let(:rows) { subject.find_relationships }
|
|
188
|
-
|
|
189
|
-
it "returns one row" do
|
|
190
|
-
expect(rows.count).to eq 1
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
it "designates the row as the latest row" do
|
|
194
|
-
expect(rows.first.latest?).to be true
|
|
195
|
-
end
|
|
196
|
-
|
|
197
|
-
it "includes the prod tag name for the row" do
|
|
198
|
-
expect(rows.first.tag_names).to eq ['prod']
|
|
199
|
-
end
|
|
200
|
-
|
|
201
|
-
it "includes the latest overall verification for the latest pact" do
|
|
202
|
-
expect(rows.first.latest_verification.provider_version_number).to eq '2.0.0'
|
|
203
|
-
end
|
|
204
|
-
end
|
|
205
130
|
end
|
|
206
131
|
|
|
207
132
|
describe "delete" do
|
|
133
|
+
|
|
208
134
|
before do
|
|
209
135
|
TestDataBuilder.new
|
|
210
136
|
.create_consumer("Consumer")
|
|
@@ -576,20 +576,19 @@ module PactBroker
|
|
|
576
576
|
describe "find_latest_pacts" do
|
|
577
577
|
before do
|
|
578
578
|
TestDataBuilder.new
|
|
579
|
-
.
|
|
580
|
-
.
|
|
581
|
-
.
|
|
582
|
-
.
|
|
583
|
-
.
|
|
584
|
-
.
|
|
585
|
-
.
|
|
586
|
-
.
|
|
587
|
-
.
|
|
588
|
-
.
|
|
589
|
-
.
|
|
590
|
-
.
|
|
591
|
-
.
|
|
592
|
-
.create_consumer_version('2.8.0') # Create a version without a pact, it shouldn't be used
|
|
579
|
+
.create_condor
|
|
580
|
+
.create_condor_version('1.3.0')
|
|
581
|
+
.create_pricing_service
|
|
582
|
+
.create_condor_pricing_service_pact
|
|
583
|
+
.create_condor_version('1.4.0')
|
|
584
|
+
.create_condor_pricing_service_pact
|
|
585
|
+
.create_contract_email_service
|
|
586
|
+
.create_contract_email_service_version('2.6.0')
|
|
587
|
+
.create_contract_proposal_service
|
|
588
|
+
.create_ces_cps_pact
|
|
589
|
+
.create_contract_email_service_version('2.7.0')
|
|
590
|
+
.create_ces_cps_pact
|
|
591
|
+
.create_contract_email_service_version('2.8.0') # Create a version without a pact, it shouldn't be used
|
|
593
592
|
end
|
|
594
593
|
|
|
595
594
|
it "finds the latest pact for each consumer/provider pair" do
|
|
@@ -601,13 +600,12 @@ module PactBroker
|
|
|
601
600
|
expect(pacts[0].provider.name).to eq("Pricing Service")
|
|
602
601
|
expect(pacts[0].provider.id).to_not be nil
|
|
603
602
|
expect(pacts[0].consumer_version.number).to eq("1.4.0")
|
|
604
|
-
expect(pacts[
|
|
603
|
+
expect(pacts[1].consumer_version.tags).to be nil # Not used, don't bother loading
|
|
605
604
|
|
|
606
605
|
expect(pacts[1].consumer_version.pacticipant.name).to eq("Contract Email Service")
|
|
607
606
|
expect(pacts[1].consumer.name).to eq("Contract Email Service")
|
|
608
607
|
expect(pacts[1].provider.name).to eq("Contract Proposal Service")
|
|
609
608
|
expect(pacts[1].consumer_version.number).to eq("2.7.0")
|
|
610
|
-
expect(pacts[1].consumer_version.tags.collect(&:name)).to eq []
|
|
611
609
|
end
|
|
612
610
|
|
|
613
611
|
it "includes the timestamps - need to update view" do
|
|
@@ -16,7 +16,7 @@ module PactBroker
|
|
|
16
16
|
|
|
17
17
|
its(:consumer_name) { should eq 'Consumer Name'}
|
|
18
18
|
its(:provider_name) { should eq 'Provider Name'}
|
|
19
|
-
its(:
|
|
19
|
+
its(:latest_pact_url) { should eq "/pacts/provider/Provider%20Name/consumer/Consumer%20Name/latest" }
|
|
20
20
|
its(:consumer_group_url) { should eq "/groups/Consumer%20Name" }
|
|
21
21
|
its(:provider_group_url) { should eq "/groups/Provider%20Name" }
|
|
22
22
|
|
|
@@ -67,8 +67,7 @@ module PactBroker
|
|
|
67
67
|
instance_double("PactBroker::Domain::Relationship",
|
|
68
68
|
webhook_status: webhook_status,
|
|
69
69
|
last_webhook_execution_date: DateTime.now - 1,
|
|
70
|
-
latest_pact: double("pact", consumer: consumer, provider: provider)
|
|
71
|
-
latest?: true
|
|
70
|
+
latest_pact: double("pact", consumer: consumer, provider: provider)
|
|
72
71
|
)
|
|
73
72
|
end
|
|
74
73
|
let(:webhook_status) { :none }
|
|
@@ -123,8 +122,10 @@ module PactBroker
|
|
|
123
122
|
expect(relationship_view_models.sort.collect{ |r| [r.consumer_name, r.provider_name]})
|
|
124
123
|
.to eq([["A", "X"],["a","y"],["A","Z"],["C", "A"]])
|
|
125
124
|
end
|
|
125
|
+
|
|
126
126
|
end
|
|
127
|
+
|
|
127
128
|
end
|
|
128
129
|
end
|
|
129
130
|
end
|
|
130
|
-
end
|
|
131
|
+
end
|