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
@@ -14,7 +14,7 @@ describe 'migrate to pact versions (migrate 22-31)', migration: true do
|
|
14
14
|
let!(:pact_2) { create(:pacts, {version_id: consumer_version_2[:id], provider_id: provider[:id], pact_version_content_sha: '1234', created_at: now, updated_at: pact_updated_at}) }
|
15
15
|
|
16
16
|
|
17
|
-
subject { PactBroker::Database.migrate
|
17
|
+
subject { PactBroker::Database.migrate }
|
18
18
|
|
19
19
|
it "keeps the same number of pacts" do
|
20
20
|
subject
|
@@ -65,7 +65,7 @@ describe 'migrate to pact versions (migrate 22-31)', migration: true do
|
|
65
65
|
subject
|
66
66
|
|
67
67
|
PactBroker::Pacts::Service.create_or_update_pact(
|
68
|
-
|
68
|
+
consumer_name: consumer[:name], provider_name: provider[:name], consumer_version_number: '1.2.3', json_content: load_fixture('a_consumer-a_provider.json')
|
69
69
|
)
|
70
70
|
end
|
71
71
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
describe 'create latest matrix (latest pact revision/latest verification for provider version)', migration: true do
|
2
2
|
before do
|
3
|
-
PactBroker::Database.migrate(
|
3
|
+
PactBroker::Database.migrate(20180129)
|
4
4
|
end
|
5
5
|
|
6
6
|
def shorten_row row
|
@@ -9,18 +9,24 @@ describe 'create latest matrix (latest pact revision/latest verification for pro
|
|
9
9
|
|
10
10
|
let(:now) { DateTime.new(2018, 2, 2) }
|
11
11
|
let!(:consumer) { create(:pacticipants, {name: 'C', created_at: now, updated_at: now}) }
|
12
|
-
let!(:
|
12
|
+
let!(:provider_1) { create(:pacticipants, {name: 'P', created_at: now, updated_at: now}) }
|
13
|
+
let!(:provider_2) { create(:pacticipants, {name: 'Q', created_at: now, updated_at: now}) }
|
13
14
|
let!(:consumer_version_1) { create(:versions, {number: '1', order: 1, pacticipant_id: consumer[:id], created_at: now, updated_at: now}) }
|
14
15
|
let!(:consumer_version_2) { create(:versions, {number: '2', order: 2, pacticipant_id: consumer[:id], created_at: now, updated_at: now}) }
|
15
|
-
let!(:
|
16
|
-
let!(:
|
17
|
-
let!(:
|
18
|
-
let!(:
|
19
|
-
|
16
|
+
let!(:provider_1_version_1) { create(:versions, {number: '1', order: 1, pacticipant_id: provider_1[:id], created_at: now, updated_at: now}) }
|
17
|
+
let!(:provider_1_version_2) { create(:versions, {number: '2', order: 2, pacticipant_id: provider_1[:id], created_at: now, updated_at: now}) }
|
18
|
+
let!(:provider_2_version_1) { create(:versions, {number: '1', order: 1, pacticipant_id: provider_2[:id], created_at: now, updated_at: now}) }
|
19
|
+
let!(:provider_2_version_2) { create(:versions, {number: '2', order: 2, pacticipant_id: provider_2[:id], created_at: now, updated_at: now}) }
|
20
|
+
|
21
|
+
let!(:pact_version_1) { create(:pact_versions, {content: {some: 'json'}.to_json, sha: '1', consumer_id: consumer[:id], provider_id: provider_1[:id], created_at: now}) }
|
22
|
+
let!(:pact_version_2) { create(:pact_versions, {content: {some: 'json other'}.to_json, sha: '2', consumer_id: consumer[:id], provider_id: provider_1[:id], created_at: now}) }
|
23
|
+
let!(:pact_version_3) { create(:pact_versions, {content: {some: 'json more'}.to_json, sha: '3', consumer_id: consumer[:id], provider_id: provider_1[:id], created_at: now}) }
|
24
|
+
let!(:pact_version_4) { create(:pact_versions, {content: {some: 'json more blah'}.to_json, sha: '4', consumer_id: consumer[:id], provider_id: provider_2[:id], created_at: now}) }
|
25
|
+
|
20
26
|
let!(:pact_publication_1) do
|
21
27
|
create(:pact_publications, {
|
22
28
|
consumer_version_id: consumer_version_1[:id],
|
23
|
-
provider_id:
|
29
|
+
provider_id: provider_1[:id],
|
24
30
|
revision_number: 1,
|
25
31
|
pact_version_id: pact_version_1[:id],
|
26
32
|
created_at: now
|
@@ -30,7 +36,7 @@ describe 'create latest matrix (latest pact revision/latest verification for pro
|
|
30
36
|
let!(:pact_publication_2) do
|
31
37
|
create(:pact_publications, {
|
32
38
|
consumer_version_id: consumer_version_1[:id],
|
33
|
-
provider_id:
|
39
|
+
provider_id: provider_1[:id],
|
34
40
|
revision_number: 2,
|
35
41
|
pact_version_id: pact_version_2[:id],
|
36
42
|
created_at: now
|
@@ -41,19 +47,30 @@ describe 'create latest matrix (latest pact revision/latest verification for pro
|
|
41
47
|
let!(:pact_publication_3) do
|
42
48
|
create(:pact_publications, {
|
43
49
|
consumer_version_id: consumer_version_2[:id],
|
44
|
-
provider_id:
|
50
|
+
provider_id: provider_1[:id],
|
45
51
|
revision_number: 1,
|
46
52
|
pact_version_id: pact_version_3[:id],
|
47
53
|
created_at: now
|
48
54
|
})
|
49
55
|
end
|
50
56
|
|
57
|
+
# C2 Q1 (r1/n1)
|
58
|
+
let!(:pact_publication_4) do
|
59
|
+
create(:pact_publications, {
|
60
|
+
consumer_version_id: consumer_version_2[:id],
|
61
|
+
provider_id: provider_2[:id],
|
62
|
+
revision_number: 1,
|
63
|
+
pact_version_id: pact_version_4[:id],
|
64
|
+
created_at: now
|
65
|
+
})
|
66
|
+
end
|
67
|
+
|
51
68
|
# C1 P3 (r1n3)
|
52
69
|
let!(:verification_1) do
|
53
70
|
create(:verifications, {
|
54
71
|
number: 1,
|
55
72
|
success: true,
|
56
|
-
provider_version_id:
|
73
|
+
provider_version_id: provider_1_version_1[:id],
|
57
74
|
pact_version_id: pact_version_1[:id],
|
58
75
|
execution_date: now,
|
59
76
|
created_at: now
|
@@ -65,7 +82,7 @@ describe 'create latest matrix (latest pact revision/latest verification for pro
|
|
65
82
|
create(:verifications, {
|
66
83
|
number: 1,
|
67
84
|
success: true,
|
68
|
-
provider_version_id:
|
85
|
+
provider_version_id: provider_1_version_1[:id],
|
69
86
|
pact_version_id: pact_version_2[:id],
|
70
87
|
execution_date: now,
|
71
88
|
created_at: now
|
@@ -77,7 +94,7 @@ describe 'create latest matrix (latest pact revision/latest verification for pro
|
|
77
94
|
create(:verifications, {
|
78
95
|
number: 2,
|
79
96
|
success: true,
|
80
|
-
provider_version_id:
|
97
|
+
provider_version_id: provider_1_version_1[:id],
|
81
98
|
pact_version_id: pact_version_2[:id],
|
82
99
|
execution_date: now,
|
83
100
|
created_at: now
|
@@ -89,25 +106,76 @@ describe 'create latest matrix (latest pact revision/latest verification for pro
|
|
89
106
|
create(:verifications, {
|
90
107
|
number: 3,
|
91
108
|
success: true,
|
92
|
-
provider_version_id:
|
109
|
+
provider_version_id: provider_1_version_2[:id],
|
93
110
|
pact_version_id: pact_version_2[:id],
|
94
111
|
execution_date: now,
|
95
112
|
created_at: now
|
96
113
|
})
|
97
114
|
end
|
98
115
|
|
116
|
+
# include
|
117
|
+
# C1 Q1 (r1/n1)
|
118
|
+
let!(:verification_5) do
|
119
|
+
create(:verifications, {
|
120
|
+
number: 1,
|
121
|
+
success: true,
|
122
|
+
provider_version_id: provider_2_version_1[:id],
|
123
|
+
pact_version_id: pact_version_4[:id],
|
124
|
+
execution_date: now,
|
125
|
+
created_at: now
|
126
|
+
})
|
127
|
+
end
|
128
|
+
|
129
|
+
# include
|
130
|
+
# C1 Q2 (r1/n2)
|
131
|
+
let!(:verification_6) do
|
132
|
+
create(:verifications, {
|
133
|
+
number: 2,
|
134
|
+
success: true,
|
135
|
+
provider_version_id: provider_2_version_2[:id],
|
136
|
+
pact_version_id: pact_version_4[:id],
|
137
|
+
execution_date: now,
|
138
|
+
created_at: now
|
139
|
+
})
|
140
|
+
end
|
141
|
+
|
99
142
|
# C1 P1 (r1/n1) this pact version is overwritten by r2
|
100
143
|
# C1 P1 (r2/n1) this verification is overwritten by n2
|
101
144
|
# C1 P1 (r2/n2)
|
102
145
|
# C1 P2 (r2/n3)
|
103
146
|
# C2 P? (r1/n?)
|
104
147
|
|
148
|
+
describe "matrix" do
|
149
|
+
it "includes every revision and every verification" do
|
150
|
+
rows = database[:matrix].order(:verification_id).all.collect{|row| shorten_row(row) }
|
151
|
+
expect(rows).to include "C1 P1 (r1/n1)"
|
152
|
+
expect(rows).to include "C1 P1 (r2/n1)"
|
153
|
+
expect(rows.count).to eq 7
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
105
157
|
it "only includes the latest pact revisions and latest verifications" do
|
106
|
-
rows = database[:
|
158
|
+
rows = database[:latest_matrix_for_consumer_version_and_provider_version].order(:verification_id).all.collect{|row| shorten_row(row) }
|
107
159
|
expect(rows).to include "C1 P1 (r2/n2)"
|
108
160
|
expect(rows).to include "C1 P2 (r2/n3)"
|
109
161
|
expect(rows).to include "C2 P? (r1/n?)"
|
162
|
+
expect(rows).to include "C2 Q1 (r1/n1)"
|
163
|
+
expect(rows).to include "C2 Q2 (r1/n2)"
|
164
|
+
expect(rows).to_not include "C1 P1 (r1/n1)"
|
110
165
|
expect(rows).to_not include "C1 P1 (r2/n1)"
|
111
|
-
expect(database[:
|
166
|
+
expect(database[:latest_matrix_for_consumer_version_and_provider_version].count).to eq 5
|
167
|
+
end
|
168
|
+
|
169
|
+
describe "latest matrix" do
|
170
|
+
it "only includes the latest pact revisions and latest verifications for the latest consumer versions" do
|
171
|
+
rows = database[:latest_matrix].order(:verification_id).all.collect{|row| shorten_row(row) }
|
172
|
+
expect(rows).to include "C2 P? (r1/n?)"
|
173
|
+
expect(rows).to include "C2 Q2 (r1/n2)"
|
174
|
+
expect(rows).to_not include "C2 Q1 (r1/n1)" # not latest provider version
|
175
|
+
expect(rows).to_not include "C1 P1 (r2/n2)" # not latest consumer version
|
176
|
+
expect(rows).to_not include "C1 P2 (r2/n3)" # not latest consumer version
|
177
|
+
expect(rows).to_not include "C1 P1 (r2/n1)" # not latest consumer version
|
178
|
+
expect(database[:latest_matrix].count).to eq 2
|
179
|
+
end
|
112
180
|
end
|
113
181
|
end
|
@@ -45,7 +45,7 @@ describe "changing from integer to timestamp migrations", no_db_clean: true do
|
|
45
45
|
it "allows data to be inserted" do
|
46
46
|
consumer_id = @db[:pacticipants].insert(name: 'Foo', created_at: DateTime.now, updated_at: DateTime.now)
|
47
47
|
provider_id = @db[:pacticipants].insert(name: 'Bar', created_at: DateTime.now, updated_at: DateTime.now)
|
48
|
-
version_id = @db[:versions].insert(number: '1.2.3', pacticipant_id: consumer_id, created_at: DateTime.now, updated_at: DateTime.now)
|
48
|
+
version_id = @db[:versions].insert(number: '1.2.3', order: 1, pacticipant_id: consumer_id, created_at: DateTime.now, updated_at: DateTime.now)
|
49
49
|
pact_json = {consumer: {name: 'Foo'}, provider: {name: 'Bar'}, interactions: []}.to_json
|
50
50
|
pact_version_id = @db[:pact_versions].insert(sha: '123', content: pact_json, created_at: DateTime.now, consumer_id: consumer_id, provider_id: provider_id)
|
51
51
|
pact_publication_id = @db[:pact_publications].insert(consumer_version_id: version_id, provider_id: provider_id, revision_number: 1, pact_version_id: pact_version_id, created_at: DateTime.now)
|
@@ -10,7 +10,10 @@ require 'pact_broker'
|
|
10
10
|
require 'pact_broker/app'
|
11
11
|
|
12
12
|
require_relative 'hal_relation_proxy_app'
|
13
|
-
|
13
|
+
|
14
|
+
Dir.glob(File.join(File.dirname(__FILE__), "provider_states_for*.rb")).each do | path |
|
15
|
+
require path
|
16
|
+
end
|
14
17
|
|
15
18
|
pact_broker = PactBroker::App.new { |c| c.database_connection = DB::PACT_BROKER_DB }
|
16
19
|
app_to_verify = HalRelationProxyApp.new(pact_broker)
|
data/spec/spec_helper.rb
CHANGED
@@ -3,7 +3,7 @@ require 'tasks/database'
|
|
3
3
|
module MigrationHelpers
|
4
4
|
def create table_name, params, id_column_name = :id
|
5
5
|
database[table_name].insert(params);
|
6
|
-
database[table_name].order(id_column_name).last
|
6
|
+
database[table_name].order(id_column_name).last if id_column_name
|
7
7
|
end
|
8
8
|
|
9
9
|
def clean table_name
|
@@ -8,8 +8,12 @@ end
|
|
8
8
|
|
9
9
|
|
10
10
|
def contains_hash?(expected, actual)
|
11
|
-
|
12
|
-
|
11
|
+
if actual.is_a?(Array)
|
12
|
+
actual.any? && actual.any?{|actual_item| contains_hash?(expected, actual_item)}
|
13
|
+
else
|
14
|
+
expected.all? do |key, value|
|
15
|
+
unordered_match(actual[key], value)
|
16
|
+
end
|
13
17
|
end
|
14
18
|
end
|
15
19
|
|
@@ -67,6 +67,6 @@ RSpec::Matchers.define :include_hash_matching do |expected|
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def slice actual, keys
|
70
|
-
keys.each_with_object({}) { |k, hash| hash[k] = actual[k] if actual.has_key?(k) }
|
70
|
+
keys.each_with_object({}) { |k, hash| hash[k] = actual[k] if (actual.respond_to?(:has_key?) && actual.has_key?(k)) || actual.respond_to?(k) }
|
71
71
|
end
|
72
72
|
end
|
@@ -22,6 +22,7 @@ require 'pact_broker/verifications/service'
|
|
22
22
|
require 'pact_broker/tags/repository'
|
23
23
|
require 'pact_broker/webhooks/repository'
|
24
24
|
require 'pact_broker/certificates/certificate'
|
25
|
+
require 'pact_broker/matrix/row'
|
25
26
|
require 'ostruct'
|
26
27
|
|
27
28
|
class TestDataBuilder
|
@@ -37,6 +38,26 @@ class TestDataBuilder
|
|
37
38
|
attr_reader :webhook
|
38
39
|
attr_reader :webhook_execution
|
39
40
|
attr_reader :triggered_webhook
|
41
|
+
attr_accessor :auto_refresh_matrix
|
42
|
+
|
43
|
+
def initialize(params = {})
|
44
|
+
@auto_refresh_matrix = params.fetch(:auto_refresh_matrix, true)
|
45
|
+
end
|
46
|
+
|
47
|
+
def comment *args
|
48
|
+
self
|
49
|
+
end
|
50
|
+
|
51
|
+
def refresh_matrix
|
52
|
+
if auto_refresh_matrix
|
53
|
+
params = {}
|
54
|
+
params[:consumer_name] = consumer.name if consumer
|
55
|
+
params[:provider_name] = provider.name if provider
|
56
|
+
matrix_service.refresh(params)
|
57
|
+
# Row is not used in production code, but the tests depend on it
|
58
|
+
PactBroker::Matrix::Row.refresh(params)
|
59
|
+
end
|
60
|
+
end
|
40
61
|
|
41
62
|
def create_pricing_service
|
42
63
|
@pricing_service_id = pacticipant_repository.create(:name => 'Pricing Service', :repository_url => 'git@git.realestate.com.au:business-systems/pricing-service').save(raise_on_save_failure: true).id
|
@@ -107,23 +128,27 @@ class TestDataBuilder
|
|
107
128
|
PactBroker::Domain::Tag.create(name: tag_name, version: version)
|
108
129
|
end
|
109
130
|
|
110
|
-
def create_pacticipant pacticipant_name
|
131
|
+
def create_pacticipant pacticipant_name, params = {}
|
132
|
+
params.delete(:comment)
|
111
133
|
@pacticipant = PactBroker::Domain::Pacticipant.create(:name => pacticipant_name)
|
112
134
|
self
|
113
135
|
end
|
114
136
|
|
115
|
-
def create_consumer consumer_name = "Consumer #{model_counter}"
|
137
|
+
def create_consumer consumer_name = "Consumer #{model_counter}", params = {}
|
138
|
+
params.delete(:comment)
|
116
139
|
create_pacticipant consumer_name
|
117
140
|
@consumer = @pacticipant
|
118
141
|
self
|
119
142
|
end
|
120
143
|
|
121
|
-
def use_consumer consumer_name
|
144
|
+
def use_consumer consumer_name, params = {}
|
145
|
+
params.delete(:comment)
|
122
146
|
@consumer = PactBroker::Domain::Pacticipant.find(:name => consumer_name)
|
123
147
|
self
|
124
148
|
end
|
125
149
|
|
126
|
-
def create_provider provider_name = "Provider #{model_counter}"
|
150
|
+
def create_provider provider_name = "Provider #{model_counter}", params = {}
|
151
|
+
params.delete(:comment)
|
127
152
|
create_pacticipant provider_name
|
128
153
|
@provider = @pacticipant
|
129
154
|
self
|
@@ -134,17 +159,20 @@ class TestDataBuilder
|
|
134
159
|
self
|
135
160
|
end
|
136
161
|
|
137
|
-
def create_version version_number = "1.0.#{model_counter}"
|
162
|
+
def create_version version_number = "1.0.#{model_counter}", params = {}
|
163
|
+
params.delete(:comment)
|
138
164
|
@version = PactBroker::Domain::Version.create(:number => version_number, :pacticipant => @pacticipant)
|
139
165
|
self
|
140
166
|
end
|
141
167
|
|
142
|
-
def create_consumer_version version_number = "1.0.#{model_counter}"
|
168
|
+
def create_consumer_version version_number = "1.0.#{model_counter}", params = {}
|
169
|
+
params.delete(:comment)
|
143
170
|
@consumer_version = PactBroker::Domain::Version.create(:number => version_number, :pacticipant => @consumer)
|
144
171
|
self
|
145
172
|
end
|
146
173
|
|
147
|
-
def create_provider_version version_number = "1.0.#{model_counter}"
|
174
|
+
def create_provider_version version_number = "1.0.#{model_counter}", params = {}
|
175
|
+
params.delete(:comment)
|
148
176
|
@version = PactBroker::Domain::Version.create(:number => version_number, :pacticipant => @provider)
|
149
177
|
@provider_version = @version
|
150
178
|
self
|
@@ -160,17 +188,20 @@ class TestDataBuilder
|
|
160
188
|
self
|
161
189
|
end
|
162
190
|
|
163
|
-
def create_tag tag_name
|
191
|
+
def create_tag tag_name, params = {}
|
192
|
+
params.delete(:comment)
|
164
193
|
@tag = PactBroker::Domain::Tag.create(name: tag_name, version: @version)
|
165
194
|
self
|
166
195
|
end
|
167
196
|
|
168
|
-
def create_consumer_version_tag tag_name
|
197
|
+
def create_consumer_version_tag tag_name, params = {}
|
198
|
+
params.delete(:comment)
|
169
199
|
@tag = PactBroker::Domain::Tag.create(name: tag_name, version: @consumer_version)
|
170
200
|
self
|
171
201
|
end
|
172
202
|
|
173
|
-
def create_provider_version_tag tag_name
|
203
|
+
def create_provider_version_tag tag_name, params = {}
|
204
|
+
params.delete(:comment)
|
174
205
|
@tag = PactBroker::Domain::Tag.create(name: tag_name, version: @provider_version)
|
175
206
|
self
|
176
207
|
end
|
@@ -181,25 +212,31 @@ class TestDataBuilder
|
|
181
212
|
end
|
182
213
|
|
183
214
|
def create_pact params = {}
|
215
|
+
params.delete(:comment)
|
184
216
|
@pact = PactBroker::Pacts::Repository.new.create({version_id: @consumer_version.id, consumer_id: @consumer.id, provider_id: @provider.id, json_content: params[:json_content] || default_json_content})
|
185
217
|
set_created_at_if_set params[:created_at], :pact_publications, {id: @pact.id}
|
186
218
|
set_created_at_if_set params[:created_at], :pact_versions, {sha: @pact.pact_version_sha}
|
187
219
|
@pact = PactBroker::Pacts::PactPublication.find(id: @pact.id).to_domain
|
220
|
+
refresh_matrix
|
188
221
|
self
|
189
222
|
end
|
190
223
|
|
191
|
-
def
|
224
|
+
def republish_same_pact params = {}
|
225
|
+
params.delete(:comment)
|
192
226
|
last_pact_version = PactBroker::Pacts::PactVersion.order(:id).last
|
193
227
|
create_pact json_content: last_pact_version.content
|
228
|
+
self
|
194
229
|
end
|
195
230
|
|
196
231
|
def revise_pact json_content = nil
|
197
232
|
json_content = json_content ? json_content : {random: rand}.to_json
|
198
233
|
@pact = PactBroker::Pacts::Repository.new.update(@pact.id, json_content: json_content)
|
234
|
+
refresh_matrix
|
199
235
|
self
|
200
236
|
end
|
201
237
|
|
202
238
|
def create_webhook params = {}
|
239
|
+
params.delete(:comment)
|
203
240
|
uuid = params[:uuid] || PactBroker::Webhooks::Service.next_uuid
|
204
241
|
event_params = params[:events] || [{ name: PactBroker::Webhooks::WebhookEvent::DEFAULT_EVENT_NAME }]
|
205
242
|
events = event_params.collect{ |e| PactBroker::Webhooks::WebhookEvent.new(e) }
|
@@ -210,6 +247,7 @@ class TestDataBuilder
|
|
210
247
|
end
|
211
248
|
|
212
249
|
def create_triggered_webhook params = {}
|
250
|
+
params.delete(:comment)
|
213
251
|
trigger_uuid = params[:trigger_uuid] || webhook_service.next_uuid
|
214
252
|
@triggered_webhook = webhook_repository.create_triggered_webhook trigger_uuid, @webhook, @pact, PactBroker::Webhooks::Service::RESOURCE_CREATION
|
215
253
|
@triggered_webhook.update(status: params[:status]) if params[:status]
|
@@ -218,6 +256,7 @@ class TestDataBuilder
|
|
218
256
|
end
|
219
257
|
|
220
258
|
def create_webhook_execution params = {}
|
259
|
+
params.delete(:comment)
|
221
260
|
logs = params[:logs] || "logs"
|
222
261
|
webhook_execution_result = PactBroker::Domain::WebhookExecutionResult.new(OpenStruct.new(code: "200"), logs, nil)
|
223
262
|
@webhook_execution = PactBroker::Webhooks::Repository.new.create_execution @triggered_webhook, webhook_execution_result
|
@@ -228,6 +267,7 @@ class TestDataBuilder
|
|
228
267
|
end
|
229
268
|
|
230
269
|
def create_deprecated_webhook_execution params = {}
|
270
|
+
params.delete(:comment)
|
231
271
|
create_webhook_execution params
|
232
272
|
Sequel::Model.db[:webhook_executions].where(id: webhook_execution.id).update(
|
233
273
|
triggered_webhook_id: nil,
|
@@ -240,16 +280,26 @@ class TestDataBuilder
|
|
240
280
|
end
|
241
281
|
|
242
282
|
def create_verification parameters = {}
|
283
|
+
parameters.delete(:comment)
|
284
|
+
tag_names = [parameters.delete(:tag_names), parameters.delete(:tag_name)].flatten.compact
|
243
285
|
provider_version_number = parameters[:provider_version] || '4.5.6'
|
244
286
|
default_parameters = {success: true, number: 1, test_results: {some: 'results'}}
|
245
287
|
parameters = default_parameters.merge(parameters)
|
246
288
|
parameters.delete(:provider_version)
|
247
289
|
verification = PactBroker::Domain::Verification.new(parameters)
|
248
290
|
@verification = PactBroker::Verifications::Repository.new.create(verification, provider_version_number, @pact)
|
291
|
+
if tag_names.any?
|
292
|
+
provider_version = PactBroker::Domain::Version.where(pacticipant_id: @provider.id, number: provider_version_number).single_record
|
293
|
+
tag_names.each do | tag_name |
|
294
|
+
PactBroker::Domain::Tag.create(name: tag_name, version: provider_version)
|
295
|
+
end
|
296
|
+
end
|
297
|
+
refresh_matrix
|
249
298
|
self
|
250
299
|
end
|
251
300
|
|
252
301
|
def create_certificate options = {path: 'spec/fixtures/single-certificate.pem'}
|
302
|
+
options.delete(:comment)
|
253
303
|
PactBroker::Certificates::Certificate.create(uuid: SecureRandom.urlsafe_base64, content: File.read(options[:path]))
|
254
304
|
self
|
255
305
|
end
|