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
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'pact_broker/matrix/row'
|
2
|
+
|
3
|
+
module PactBroker
|
4
|
+
module Matrix
|
5
|
+
describe Row do
|
6
|
+
describe "<=>" do
|
7
|
+
let(:row_1) do
|
8
|
+
Row.new(
|
9
|
+
consumer_name: 'A',
|
10
|
+
consumer_version_order: 1,
|
11
|
+
pact_revision_number: 1,
|
12
|
+
provider_name: 'B',
|
13
|
+
provider_version_order: 1,
|
14
|
+
verification_id: 1
|
15
|
+
)
|
16
|
+
end
|
17
|
+
let(:row_2) do
|
18
|
+
Row.new(
|
19
|
+
consumer_name: 'A',
|
20
|
+
consumer_version_order: 1,
|
21
|
+
pact_revision_number: 1,
|
22
|
+
provider_name: 'B',
|
23
|
+
provider_version_order: 1,
|
24
|
+
verification_id: 2
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "sorts" do
|
29
|
+
expect([row_1, row_2].sort).to eq [row_2, row_1]
|
30
|
+
end
|
31
|
+
|
32
|
+
context "with a nil column" do
|
33
|
+
let(:row_2) do
|
34
|
+
Row.new(
|
35
|
+
consumer_name: 'A',
|
36
|
+
consumer_version_order: 1,
|
37
|
+
pact_revision_number: 1,
|
38
|
+
provider_name: 'B',
|
39
|
+
provider_version_order: nil,
|
40
|
+
verification_id: nil
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "sorts the rows first" do
|
45
|
+
expect([row_1, row_2].sort).to eq [row_2, row_1]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
describe 'create latest matrix (latest pact revision/latest verification for provider version)', migration: true do
|
2
|
+
before do
|
3
|
+
PactBroker::Database.migrate(50)
|
4
|
+
end
|
5
|
+
|
6
|
+
def shorten_row row
|
7
|
+
"#{row[:consumer_name]}#{row[:consumer_version_number]} #{row[:provider_name]}#{row[:provider_version_number] || '?'} (r#{row[:pact_revision_number]}/n#{row[:verification_number] || '?'})"
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:now) { DateTime.new(2018, 2, 2) }
|
11
|
+
let!(:consumer) { create(:pacticipants, {name: 'C', created_at: now, updated_at: now}) }
|
12
|
+
let!(:provider) { create(:pacticipants, {name: 'P', created_at: now, updated_at: now}) }
|
13
|
+
let!(:consumer_version_1) { create(:versions, {number: '1', order: 1, pacticipant_id: consumer[:id], created_at: now, updated_at: now}) }
|
14
|
+
let!(:consumer_version_2) { create(:versions, {number: '2', order: 2, pacticipant_id: consumer[:id], created_at: now, updated_at: now}) }
|
15
|
+
let!(:provider_version_1) { create(:versions, {number: '1', order: 1, pacticipant_id: provider[:id], created_at: now, updated_at: now}) }
|
16
|
+
let!(:provider_version_2) { create(:versions, {number: '2', order: 2, pacticipant_id: provider[:id], created_at: now, updated_at: now}) }
|
17
|
+
let!(:pact_version_1) { create(:pact_versions, {content: {some: 'json'}.to_json, sha: '1', consumer_id: consumer[:id], provider_id: provider[:id], created_at: now}) }
|
18
|
+
let!(:pact_version_2) { create(:pact_versions, {content: {some: 'json other'}.to_json, sha: '2', consumer_id: consumer[:id], provider_id: provider[:id], created_at: now}) }
|
19
|
+
let!(:pact_version_3) { create(:pact_versions, {content: {some: 'json more'}.to_json, sha: '3', consumer_id: consumer[:id], provider_id: provider[:id], created_at: now}) }
|
20
|
+
let!(:pact_publication_1) do
|
21
|
+
create(:pact_publications, {
|
22
|
+
consumer_version_id: consumer_version_1[:id],
|
23
|
+
provider_id: provider[:id],
|
24
|
+
revision_number: 1,
|
25
|
+
pact_version_id: pact_version_1[:id],
|
26
|
+
created_at: now
|
27
|
+
})
|
28
|
+
end
|
29
|
+
|
30
|
+
let!(:pact_publication_2) do
|
31
|
+
create(:pact_publications, {
|
32
|
+
consumer_version_id: consumer_version_1[:id],
|
33
|
+
provider_id: provider[:id],
|
34
|
+
revision_number: 2,
|
35
|
+
pact_version_id: pact_version_2[:id],
|
36
|
+
created_at: now
|
37
|
+
})
|
38
|
+
end
|
39
|
+
|
40
|
+
# C2 P? (r1/n?)
|
41
|
+
let!(:pact_publication_3) do
|
42
|
+
create(:pact_publications, {
|
43
|
+
consumer_version_id: consumer_version_2[:id],
|
44
|
+
provider_id: provider[:id],
|
45
|
+
revision_number: 1,
|
46
|
+
pact_version_id: pact_version_3[:id],
|
47
|
+
created_at: now
|
48
|
+
})
|
49
|
+
end
|
50
|
+
|
51
|
+
# C1 P3 (r1n3)
|
52
|
+
let!(:verification_1) do
|
53
|
+
create(:verifications, {
|
54
|
+
number: 1,
|
55
|
+
success: true,
|
56
|
+
provider_version_id: provider_version_1[:id],
|
57
|
+
pact_version_id: pact_version_1[:id],
|
58
|
+
execution_date: now,
|
59
|
+
created_at: now
|
60
|
+
})
|
61
|
+
end
|
62
|
+
|
63
|
+
# C1 P3 (r1n1)
|
64
|
+
let!(:verification_2) do
|
65
|
+
create(:verifications, {
|
66
|
+
number: 1,
|
67
|
+
success: true,
|
68
|
+
provider_version_id: provider_version_1[:id],
|
69
|
+
pact_version_id: pact_version_2[:id],
|
70
|
+
execution_date: now,
|
71
|
+
created_at: now
|
72
|
+
})
|
73
|
+
end
|
74
|
+
|
75
|
+
# include
|
76
|
+
let!(:verification_3) do
|
77
|
+
create(:verifications, {
|
78
|
+
number: 2,
|
79
|
+
success: true,
|
80
|
+
provider_version_id: provider_version_1[:id],
|
81
|
+
pact_version_id: pact_version_2[:id],
|
82
|
+
execution_date: now,
|
83
|
+
created_at: now
|
84
|
+
})
|
85
|
+
end
|
86
|
+
|
87
|
+
# include
|
88
|
+
let!(:verification_4) do
|
89
|
+
create(:verifications, {
|
90
|
+
number: 3,
|
91
|
+
success: true,
|
92
|
+
provider_version_id: provider_version_2[:id],
|
93
|
+
pact_version_id: pact_version_2[:id],
|
94
|
+
execution_date: now,
|
95
|
+
created_at: now
|
96
|
+
})
|
97
|
+
end
|
98
|
+
|
99
|
+
# C1 P1 (r1/n1) this pact version is overwritten by r2
|
100
|
+
# C1 P1 (r2/n1) this verification is overwritten by n2
|
101
|
+
# C1 P1 (r2/n2)
|
102
|
+
# C1 P2 (r2/n3)
|
103
|
+
# C2 P? (r1/n?)
|
104
|
+
|
105
|
+
it "only includes the latest pact revisions and latest verifications" do
|
106
|
+
rows = database[:latest_matrix].order(:verification_id).all.collect{|row| shorten_row(row) }
|
107
|
+
expect(rows).to include "C1 P1 (r2/n2)"
|
108
|
+
expect(rows).to include "C1 P2 (r2/n3)"
|
109
|
+
expect(rows).to include "C2 P? (r1/n?)"
|
110
|
+
expect(rows).to_not include "C1 P1 (r2/n1)"
|
111
|
+
expect(database[:latest_matrix].count).to eq 3
|
112
|
+
end
|
113
|
+
end
|
@@ -6,10 +6,12 @@ Pact.provider_states_for "Pact Broker Client" do
|
|
6
6
|
set_up do
|
7
7
|
TestDataBuilder.new
|
8
8
|
.create_pact_with_hierarchy("Foo Thing", "1.2.3", "Bar")
|
9
|
+
.revise_pact
|
9
10
|
.create_verification(provider_version: "4.5.6")
|
10
11
|
.create_verification(provider_version: "7.8.9", number: 2)
|
11
12
|
.create_consumer_version("2.0.0")
|
12
13
|
.create_pact
|
14
|
+
.revise_pact
|
13
15
|
.create_verification(provider_version: "4.5.6")
|
14
16
|
end
|
15
17
|
end
|
@@ -18,10 +20,12 @@ Pact.provider_states_for "Pact Broker Client" do
|
|
18
20
|
set_up do
|
19
21
|
TestDataBuilder.new
|
20
22
|
.create_pact_with_hierarchy("Foo", "1.2.3", "Bar")
|
23
|
+
.revise_pact
|
21
24
|
.create_verification(provider_version: "4.5.6")
|
22
25
|
.create_verification(provider_version: "7.8.9", number: 2)
|
23
26
|
.create_consumer_version("2.0.0")
|
24
27
|
.create_pact
|
28
|
+
.revise_pact
|
25
29
|
.create_verification(provider_version: "4.5.6")
|
26
30
|
end
|
27
31
|
end
|
@@ -30,9 +34,11 @@ Pact.provider_states_for "Pact Broker Client" do
|
|
30
34
|
set_up do
|
31
35
|
TestDataBuilder.new
|
32
36
|
.create_pact_with_hierarchy("Foo", "1.2.3", "Bar")
|
37
|
+
.revise_pact
|
33
38
|
.create_verification(provider_version: "4.5.6")
|
34
39
|
.create_consumer_version("1.2.4")
|
35
40
|
.create_pact
|
41
|
+
.revise_pact
|
36
42
|
.create_verification(provider_version: "4.5.6")
|
37
43
|
end
|
38
44
|
end
|
@@ -41,26 +47,40 @@ Pact.provider_states_for "Pact Broker Client" do
|
|
41
47
|
set_up do
|
42
48
|
TestDataBuilder.new
|
43
49
|
.create_pact_with_hierarchy("Foo", "1.2.3", "Bar")
|
50
|
+
.revise_pact
|
44
51
|
.create_verification(provider_version: "4.5.6")
|
45
52
|
.create_consumer_version("1.2.4")
|
46
53
|
.create_pact
|
54
|
+
.revise_pact
|
47
55
|
.create_verification(provider_version: "9.9.9", success: false)
|
48
56
|
end
|
49
57
|
end
|
50
58
|
|
51
59
|
provider_state "the pact for Foo version 1.2.3 has been successfully verified by Bar version 4.5.6 with tag prod, and 1.2.4 unsuccessfully by 9.9.9" do
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
60
|
+
set_up do
|
61
|
+
TestDataBuilder.new
|
62
|
+
.create_pact_with_hierarchy("Foo", "1.2.3", "Bar")
|
63
|
+
.revise_pact
|
64
|
+
.create_verification(provider_version: "4.5.6")
|
65
|
+
.use_provider("Bar")
|
66
|
+
.use_provider_version("4.5.6")
|
67
|
+
.create_provider_version_tag("prod")
|
68
|
+
.create_consumer_version("1.2.4")
|
69
|
+
.create_pact
|
70
|
+
.revise_pact
|
71
|
+
.create_verification(provider_version: "9.9.9", success: false)
|
63
72
|
end
|
73
|
+
end
|
74
|
+
|
75
|
+
provider_state "the pact for Foo version 1.2.3 has been verified by Bar version 4.5.6 and version 5.6.7" do
|
76
|
+
set_up do
|
77
|
+
TestDataBuilder.new
|
78
|
+
.create_pact_with_hierarchy("Foo", "1.2.3", "Bar")
|
79
|
+
.revise_pact
|
80
|
+
.create_verification(provider_version: "4.5.6")
|
81
|
+
.create_verification(provider_version: "5.6.7", number: 2)
|
82
|
+
end
|
83
|
+
end
|
64
84
|
|
65
85
|
provider_state "the 'Pricing Service' does not exist in the pact-broker" do
|
66
86
|
no_op
|
@@ -42,11 +42,30 @@ RSpec::Matchers.define :be_a_404_response do
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
+
RSpec::Matchers.define :include_hashes_matching do |expected_array_of_hashes|
|
46
|
+
match do |array_of_hashes|
|
47
|
+
expected_array_of_hashes.each do | expected |
|
48
|
+
expect(array_of_hashes).to include_hash_matching(expected)
|
49
|
+
end
|
50
|
+
|
51
|
+
expect(array_of_hashes.size).to eq expected_array_of_hashes.size
|
52
|
+
end
|
53
|
+
|
54
|
+
def slice actual, keys
|
55
|
+
keys.each_with_object({}) { |k, hash| hash[k] = actual[k] if actual.has_key?(k) }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
45
59
|
RSpec::Matchers.define :include_hash_matching do |expected|
|
46
60
|
match do |array_of_hashes|
|
61
|
+
@array_of_hashes = array_of_hashes
|
47
62
|
array_of_hashes.any? { |actual| slice(actual, expected.keys) == expected }
|
48
63
|
end
|
49
64
|
|
65
|
+
failure_message do
|
66
|
+
"expected #{@array_of_hashes.inspect} to include #{expected.inspect}"
|
67
|
+
end
|
68
|
+
|
50
69
|
def slice actual, keys
|
51
70
|
keys.each_with_object({}) { |k, hash| hash[k] = actual[k] if actual.has_key?(k) }
|
52
71
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pact_broker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.8.0.beta.
|
4
|
+
version: 2.8.0.beta.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bethany Skurrie
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-11-
|
13
|
+
date: 2017-11-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: httparty
|
@@ -524,6 +524,9 @@ files:
|
|
524
524
|
- db/migrations/000045_set_verification_provider_number_nullable.rb
|
525
525
|
- db/migrations/000046_recreate_latest_verifications.rb
|
526
526
|
- db/migrations/000047_create_all_verifications.rb
|
527
|
+
- db/migrations/000048_create_matrix.rb
|
528
|
+
- db/migrations/000049_create_latest_verifications_for_cv_and_pv.rb
|
529
|
+
- db/migrations/000050_create_latest_matrix.rb
|
527
530
|
- db/migrations/migration_helper.rb
|
528
531
|
- db/pact_broker_database.sqlite3
|
529
532
|
- db/test/backwards_compatibility/.rspec
|
@@ -696,8 +699,10 @@ files:
|
|
696
699
|
- lib/pact_broker/labels/service.rb
|
697
700
|
- lib/pact_broker/locale/en.yml
|
698
701
|
- lib/pact_broker/logging.rb
|
702
|
+
- lib/pact_broker/matrix/latest_row.rb
|
699
703
|
- lib/pact_broker/matrix/parse_query.rb
|
700
704
|
- lib/pact_broker/matrix/repository.rb
|
705
|
+
- lib/pact_broker/matrix/row.rb
|
701
706
|
- lib/pact_broker/matrix/service.rb
|
702
707
|
- lib/pact_broker/messages.rb
|
703
708
|
- lib/pact_broker/pacticipants/find_potential_duplicate_pacticipant_names.rb
|
@@ -926,6 +931,7 @@ files:
|
|
926
931
|
- spec/lib/pact_broker/labels/service_spec.rb
|
927
932
|
- spec/lib/pact_broker/matrix/parse_query_spec.rb
|
928
933
|
- spec/lib/pact_broker/matrix/repository_spec.rb
|
934
|
+
- spec/lib/pact_broker/matrix/row_spec.rb
|
929
935
|
- spec/lib/pact_broker/matrix/service_spec.rb
|
930
936
|
- spec/lib/pact_broker/messages_spec.rb
|
931
937
|
- spec/lib/pact_broker/pacticipants/find_potential_duplicate_pacticipant_names_spec.rb
|
@@ -969,6 +975,7 @@ files:
|
|
969
975
|
- spec/migrations/41_migrate_execution_data_spec.rb
|
970
976
|
- spec/migrations/42_delete_ophan_webhook_data_spec.rb
|
971
977
|
- spec/migrations/44_add_provider_version_to_verification_spec.rb
|
978
|
+
- spec/migrations/50_create_latest_matrix_spec.rb
|
972
979
|
- spec/migrations/change_migration_strategy_spec.rb
|
973
980
|
- spec/service_consumers/pact_helper.rb
|
974
981
|
- spec/service_consumers/provider_states_for_pact_broker_client.rb
|
@@ -1160,6 +1167,7 @@ test_files:
|
|
1160
1167
|
- spec/lib/pact_broker/labels/service_spec.rb
|
1161
1168
|
- spec/lib/pact_broker/matrix/parse_query_spec.rb
|
1162
1169
|
- spec/lib/pact_broker/matrix/repository_spec.rb
|
1170
|
+
- spec/lib/pact_broker/matrix/row_spec.rb
|
1163
1171
|
- spec/lib/pact_broker/matrix/service_spec.rb
|
1164
1172
|
- spec/lib/pact_broker/messages_spec.rb
|
1165
1173
|
- spec/lib/pact_broker/pacticipants/find_potential_duplicate_pacticipant_names_spec.rb
|
@@ -1203,6 +1211,7 @@ test_files:
|
|
1203
1211
|
- spec/migrations/41_migrate_execution_data_spec.rb
|
1204
1212
|
- spec/migrations/42_delete_ophan_webhook_data_spec.rb
|
1205
1213
|
- spec/migrations/44_add_provider_version_to_verification_spec.rb
|
1214
|
+
- spec/migrations/50_create_latest_matrix_spec.rb
|
1206
1215
|
- spec/migrations/change_migration_strategy_spec.rb
|
1207
1216
|
- spec/service_consumers/pact_helper.rb
|
1208
1217
|
- spec/service_consumers/provider_states_for_pact_broker_client.rb
|