pact_broker 2.38.1 → 2.39.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/ISSUE_TEMPLATE.md +2 -2
- data/CHANGELOG.md +45 -0
- data/DEVELOPER_DOCUMENTATION.md +9 -0
- data/Dockerfile +2 -0
- data/Gemfile +1 -1
- data/README.md +10 -3
- data/config/database.yml +10 -2
- data/docs/images/Pactflow logo - black small.png +0 -0
- data/lib/pact_broker/api.rb +5 -2
- data/lib/pact_broker/api/contracts/verifiable_pacts_query_schema.rb +41 -0
- data/lib/pact_broker/api/decorators/dashboard_decorator.rb +1 -1
- data/lib/pact_broker/api/decorators/dashboard_text_decorator.rb +1 -1
- data/lib/pact_broker/api/decorators/integration_decorator.rb +2 -0
- data/lib/pact_broker/api/decorators/verifiable_pact_decorator.rb +34 -0
- data/lib/pact_broker/api/decorators/verifiable_pacts_query_decorator.rb +27 -0
- data/lib/pact_broker/api/resources/badge.rb +4 -4
- data/lib/pact_broker/api/resources/can_i_deploy.rb +41 -0
- data/lib/pact_broker/api/resources/dashboard.rb +1 -1
- data/lib/pact_broker/api/resources/index.rb +15 -4
- data/lib/pact_broker/api/resources/latest_pact.rb +10 -4
- data/lib/pact_broker/api/resources/latest_verification_for_latest_pact.rb +19 -0
- data/lib/pact_broker/api/resources/pact.rb +5 -4
- data/lib/pact_broker/api/resources/provider_pacts_for_verification.rb +54 -0
- data/lib/pact_broker/api/resources/verification.rb +6 -1
- data/lib/pact_broker/badges/service.rb +11 -11
- data/lib/pact_broker/db/clean.rb +72 -12
- data/lib/pact_broker/doc/controllers/app.rb +3 -1
- data/lib/pact_broker/doc/views/can-i-deploy.markdown +14 -0
- data/lib/pact_broker/doc/views/index/pacticipant-version-tag.markdown +8 -0
- data/lib/pact_broker/doc/views/integrations.markdown +1 -1
- data/lib/pact_broker/doc/views/matrix.markdown +7 -0
- data/lib/pact_broker/doc/views/metrics.markdown +5 -0
- data/lib/pact_broker/domain/index_item.rb +3 -3
- data/lib/pact_broker/domain/pact.rb +28 -1
- data/lib/pact_broker/index/service.rb +38 -20
- data/lib/pact_broker/integrations/integration.rb +16 -0
- data/lib/pact_broker/integrations/service.rb +15 -1
- data/lib/pact_broker/matrix/can_i_deploy_query_schema.rb +25 -0
- data/lib/pact_broker/matrix/parse_can_i_deploy_query.rb +29 -0
- data/lib/pact_broker/matrix/quick_row.rb +255 -0
- data/lib/pact_broker/matrix/repository.rb +5 -17
- data/lib/pact_broker/matrix/row.rb +0 -1
- data/lib/pact_broker/metrics/service.rb +36 -2
- data/lib/pact_broker/pacts/all_pact_publications.rb +3 -2
- data/lib/pact_broker/pacts/head_pact.rb +30 -0
- data/lib/pact_broker/pacts/latest_pact_publications.rb +8 -1
- data/lib/pact_broker/pacts/latest_tagged_pact_publications.rb +5 -1
- data/lib/pact_broker/pacts/pact_publication.rb +2 -1
- data/lib/pact_broker/pacts/pact_version.rb +20 -0
- data/lib/pact_broker/pacts/repository.rb +33 -4
- data/lib/pact_broker/pacts/service.rb +15 -2
- data/lib/pact_broker/pacts/squash_pacts_for_verification.rb +37 -0
- data/lib/pact_broker/pacts/verifiable_pact.rb +30 -0
- data/lib/pact_broker/pacts/verifiable_pact_messages.rb +75 -0
- data/lib/pact_broker/test/test_data_builder.rb +30 -2
- data/lib/pact_broker/ui/view_models/index_item.rb +4 -4
- data/lib/pact_broker/ui/view_models/matrix_line.rb +1 -1
- data/lib/pact_broker/ui/views/index/show-with-tags.haml +1 -1
- data/lib/pact_broker/ui/views/index/show.haml +1 -1
- data/lib/pact_broker/ui/views/matrix/show.haml +2 -2
- data/lib/pact_broker/verifications/{verification_status.rb → pseudo_branch_status.rb} +10 -4
- data/lib/pact_broker/version.rb +1 -1
- data/script/docker/mysql-db-start.sh +10 -0
- data/spec/features/can_i_deploy_spec.rb +31 -0
- data/spec/features/get_latest_verification_for_pact_spec.rb +17 -0
- data/spec/features/get_provider_pacts_for_verification_spec.rb +39 -0
- data/spec/features/metrics_spec.rb +1 -1
- data/spec/features/pending_pacts_spec.rb +109 -0
- data/spec/integration/ui/matrix_spec.rb +30 -0
- data/spec/lib/pact_broker/api/contracts/verifiable_pacts_query_schema_spec.rb +62 -0
- data/spec/lib/pact_broker/api/decorators/dashboard_decorator_spec.rb +1 -1
- data/spec/lib/pact_broker/api/decorators/integration_decorator_spec.rb +5 -1
- data/spec/lib/pact_broker/api/decorators/verifiable_pact_decorator_spec.rb +30 -5
- data/spec/lib/pact_broker/api/decorators/verifiable_pacts_query_decorator_spec.rb +46 -0
- data/spec/lib/pact_broker/api/resources/badge_spec.rb +3 -3
- data/spec/lib/pact_broker/api/resources/provider_pacts_for_verification_spec.rb +35 -0
- data/spec/lib/pact_broker/api/resources/verification_spec.rb +18 -0
- data/spec/lib/pact_broker/badges/service_spec.rb +18 -18
- data/spec/lib/pact_broker/db/clean_spec.rb +69 -8
- data/spec/lib/pact_broker/doc/coverage_spec.rb +8 -2
- data/spec/lib/pact_broker/index/service_spec.rb +28 -14
- data/spec/lib/pact_broker/integrations/integration_spec.rb +60 -0
- data/spec/lib/pact_broker/integrations/service_spec.rb +27 -0
- data/spec/lib/pact_broker/matrix/quick_row_spec.rb +31 -0
- data/spec/lib/pact_broker/matrix/repository_spec.rb +8 -8
- data/spec/lib/pact_broker/matrix/service_spec.rb +4 -4
- data/spec/lib/pact_broker/metrics/service_spec.rb +56 -0
- data/spec/lib/pact_broker/pacts/pact_version_spec.rb +69 -0
- data/spec/lib/pact_broker/pacts/repository_find_for_verification_spec.rb +65 -0
- data/spec/lib/pact_broker/pacts/repository_find_wip_pact_versions_for_provider_spec.rb +54 -24
- data/spec/lib/pact_broker/pacts/service_find_for_verification_spec.rb +51 -0
- data/spec/lib/pact_broker/pacts/squash_pacts_for_verification_spec.rb +92 -0
- data/spec/lib/pact_broker/pacts/verifiable_pact_messages_spec.rb +93 -0
- data/spec/lib/pact_broker/pacts/verifiable_pact_spec.rb +0 -0
- data/spec/lib/pact_broker/ui/view_models/index_item_spec.rb +10 -10
- data/spec/lib/pact_broker/verifications/{verification_status_spec.rb → pseudo_branch_status_spec.rb} +4 -4
- data/spec/support/shared_examples_for_responses.rb +7 -1
- metadata +56 -13
- data/lib/pact_broker/api/resources/pending_provider_pacts.rb +0 -21
- data/spec/features/get_pacts_to_verify_spec.rb +0 -41
- data/spec/features/get_wip_provider_pacts_spec.rb +0 -26
- data/spec/lib/pact_broker/api/resources/pending_provider_pacts_spec.rb +0 -34
@@ -5,77 +5,107 @@ module PactBroker
|
|
5
5
|
describe Repository do
|
6
6
|
let(:td) { TestDataBuilder.new }
|
7
7
|
|
8
|
-
describe "
|
9
|
-
subject { Repository.new.find_pending_pact_versions_for_provider("bar") }
|
8
|
+
describe "find_wip_pact_versions_for_provider" do
|
10
9
|
|
11
|
-
|
10
|
+
let(:provider_tags) { %w[dev] }
|
11
|
+
subject { Repository.new.find_wip_pact_versions_for_provider("bar", provider_tags) }
|
12
|
+
|
13
|
+
context "when there are no tags" do
|
14
|
+
let(:provider_tags) { [] }
|
15
|
+
|
16
|
+
it "returns an empty list" do
|
17
|
+
expect(subject).to eq []
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "when the latest pact for a tag has been successfully verified by the given provider tag" do
|
12
22
|
before do
|
13
23
|
td.create_pact_with_hierarchy("foo", "1", "bar")
|
14
24
|
.comment("above not included because it's not the latest prod")
|
15
25
|
.create_consumer_version("2")
|
16
26
|
.create_consumer_version_tag("prod")
|
17
27
|
.create_pact
|
18
|
-
.create_verification(provider_version: "3", comment: "not included because already verified")
|
28
|
+
.create_verification(provider_version: "3", tag_names: %w[dev], comment: "not included because already verified")
|
19
29
|
end
|
20
30
|
|
31
|
+
let(:provider_tags) { %w[dev] }
|
32
|
+
|
21
33
|
it "is not included" do
|
22
34
|
expect(subject.size).to be 0
|
23
35
|
end
|
24
36
|
end
|
25
37
|
|
26
|
-
context "when the latest pact
|
38
|
+
context "when the latest pact for a tag has been successfully verified by one of the given provider tags, but not the other" do
|
27
39
|
before do
|
28
40
|
td.create_pact_with_hierarchy("foo", "1", "bar")
|
29
|
-
.
|
41
|
+
.create_consumer_version_tag("prod")
|
42
|
+
.create_verification(provider_version: "3", tag_names: %w[dev], comment: "not included because already verified")
|
30
43
|
end
|
31
44
|
|
45
|
+
let(:provider_tags) { %w[dev feat-1] }
|
46
|
+
|
32
47
|
it "is included" do
|
33
48
|
expect(subject.size).to be 1
|
34
49
|
end
|
50
|
+
|
51
|
+
it "sets the pending tags to the tag that has not yet been verified" do
|
52
|
+
expect(subject.first.pending_provider_tags).to eq %w[feat-1]
|
53
|
+
end
|
35
54
|
end
|
36
55
|
|
37
|
-
context "when the latest pact
|
56
|
+
context "when the latest pact for a tag has failed verification from the specified provider version" do
|
38
57
|
before do
|
39
58
|
td.create_pact_with_hierarchy("foo", "1", "bar")
|
40
|
-
.
|
41
|
-
.
|
59
|
+
.create_consumer_version_tag("feat-1")
|
60
|
+
.create_verification(provider_version: "3", success: false, tag_names: %[dev])
|
42
61
|
end
|
43
62
|
|
44
63
|
it "is included" do
|
45
|
-
expect(subject.first.consumer_version_number).to eq "2"
|
46
64
|
expect(subject.size).to be 1
|
47
65
|
end
|
66
|
+
|
67
|
+
it "sets the pending tags" do
|
68
|
+
expect(subject.first.pending_provider_tags).to eq %w[dev]
|
69
|
+
end
|
48
70
|
end
|
49
71
|
|
50
|
-
context "when
|
72
|
+
context "when there are no consumer tags" do
|
51
73
|
before do
|
52
74
|
td.create_pact_with_hierarchy("foo", "1", "bar")
|
53
|
-
.
|
54
|
-
.create_verification(provider_version: "3", success: true)
|
55
|
-
.create_consumer_version("2", tag_names: ["prod"])
|
56
|
-
.create_pact
|
57
|
-
.create_verification(provider_version: "5", success: false)
|
75
|
+
.create_verification(provider_version: "3", success: false, tag_names: %[dev])
|
58
76
|
end
|
59
77
|
|
60
|
-
it "
|
61
|
-
expect(subject
|
62
|
-
|
78
|
+
it "returns an empty list" do
|
79
|
+
expect(subject).to eq []
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context "when the latest pact for a tag has successful and failed verifications" do
|
84
|
+
before do
|
85
|
+
td.create_pact_with_hierarchy("foo", "1", "bar")
|
86
|
+
.create_consumer_version_tag("dev")
|
87
|
+
.create_verification(provider_version: "3", success: true, tag_names: %[dev])
|
88
|
+
.create_verification(provider_version: "5", success: false, number: 2, tag_names: %[dev])
|
89
|
+
end
|
90
|
+
|
91
|
+
it "is not included, but maybe it should be? can't really work out a scenario where this is likely to happen" do
|
92
|
+
expect(subject).to eq []
|
63
93
|
end
|
64
94
|
end
|
65
95
|
|
66
96
|
context "when the latest pact for a tag has not been verified" do
|
67
97
|
before do
|
68
98
|
td.create_pact_with_hierarchy("foo", "1", "bar")
|
69
|
-
.create_consumer_version_tag("
|
70
|
-
.create_verification(provider_version: "5")
|
71
|
-
.create_consumer_version("2", tag_names: ["prod"])
|
72
|
-
.create_pact
|
99
|
+
.create_consumer_version_tag("dev")
|
73
100
|
end
|
74
101
|
|
75
102
|
it "is included" do
|
76
|
-
expect(subject.first.consumer_version_number).to eq "2"
|
77
103
|
expect(subject.size).to be 1
|
78
104
|
end
|
105
|
+
|
106
|
+
it "sets the pending tags" do
|
107
|
+
expect(subject.first.pending_provider_tags).to eq %w[dev]
|
108
|
+
end
|
79
109
|
end
|
80
110
|
|
81
111
|
context "when the provider name does not match the given provider name" do
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'pact_broker/pacts/service'
|
3
|
+
require 'pact_broker/pacts/pact_params'
|
4
|
+
|
5
|
+
|
6
|
+
module PactBroker
|
7
|
+
|
8
|
+
module Pacts
|
9
|
+
describe Service do
|
10
|
+
let(:td) { TestDataBuilder.new }
|
11
|
+
|
12
|
+
describe "find_for_verification" do
|
13
|
+
include_context "stubbed repositories"
|
14
|
+
|
15
|
+
let(:head_pacts) { [pact_1, pact_2] }
|
16
|
+
let(:head_tag_1) { "dev" }
|
17
|
+
let(:head_tag_2) { "feat-x" }
|
18
|
+
let(:pact_version_sha_1) { "1" }
|
19
|
+
let(:pact_version_sha_2) { "2" }
|
20
|
+
let(:domain_pact_1) { double('pact1', pending?: true) }
|
21
|
+
let(:domain_pact_2) { double('pact2', pending?: true) }
|
22
|
+
|
23
|
+
let(:pact_1) do
|
24
|
+
double("HeadPact",
|
25
|
+
head_tag: head_tag_1,
|
26
|
+
pact_version_sha: pact_version_sha_1,
|
27
|
+
pact: domain_pact_1
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
let(:pact_2) do
|
32
|
+
double("HeadPact",
|
33
|
+
head_tag: head_tag_2,
|
34
|
+
pact_version_sha: pact_version_sha_2,
|
35
|
+
pact: domain_pact_2
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
let(:provider_name) { "Bar" }
|
40
|
+
let(:provider_version_tags) { [] }
|
41
|
+
let(:consumer_version_selectors) { [] }
|
42
|
+
|
43
|
+
before do
|
44
|
+
allow(pact_repository).to receive(:find_for_verification).and_return(head_pacts)
|
45
|
+
end
|
46
|
+
|
47
|
+
subject { Service.find_for_verification(provider_name, provider_version_tags, consumer_version_selectors) }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'pact_broker/pacts/squash_pacts_for_verification'
|
2
|
+
|
3
|
+
module PactBroker
|
4
|
+
module Pacts
|
5
|
+
module SquashPactsForVerification
|
6
|
+
describe ".call" do
|
7
|
+
let(:head_pacts) { [pact_1, pact_2] }
|
8
|
+
let(:head_tag_1) { "dev" }
|
9
|
+
let(:head_tag_2) { "feat-x" }
|
10
|
+
let(:pact_version_sha_1) { "1" }
|
11
|
+
let(:pact_version_sha_2) { "2" }
|
12
|
+
let(:domain_pact_1) do
|
13
|
+
double('pact1',
|
14
|
+
pending?: pending_1,
|
15
|
+
select_pending_provider_version_tags: pending_provider_version_tags
|
16
|
+
)
|
17
|
+
end
|
18
|
+
let(:domain_pact_2) { double('pact2', pending?: pending_2) }
|
19
|
+
let(:pending_1) { false }
|
20
|
+
let(:pending_2) { false }
|
21
|
+
let(:pending_provider_version_tags) { [] }
|
22
|
+
|
23
|
+
let(:pact_1) do
|
24
|
+
double("HeadPact",
|
25
|
+
tag: head_tag_1,
|
26
|
+
pact_version_sha: pact_version_sha_1,
|
27
|
+
pact: domain_pact_1
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
let(:pact_2) do
|
32
|
+
double("HeadPact",
|
33
|
+
tag: head_tag_2,
|
34
|
+
pact_version_sha: pact_version_sha_2,
|
35
|
+
pact: domain_pact_2
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
let(:provider_name) { "Bar" }
|
40
|
+
let(:provider_version_tags) { [] }
|
41
|
+
|
42
|
+
subject { SquashPactsForVerification.call(provider_version_tags, head_pacts) }
|
43
|
+
|
44
|
+
context "when all of the consumer tags are not nil" do
|
45
|
+
its(:head_consumer_tags) { is_expected.to eq %w[dev feat-x] }
|
46
|
+
its(:overall_latest?) { is_expected.to be false }
|
47
|
+
end
|
48
|
+
|
49
|
+
context "when one of the consumer tags is nil" do
|
50
|
+
let(:head_tag_2) { nil }
|
51
|
+
its(:head_consumer_tags) { is_expected.to eq %w[dev] }
|
52
|
+
its(:overall_latest?) { is_expected.to be true }
|
53
|
+
end
|
54
|
+
|
55
|
+
context "when there are no provider tags" do
|
56
|
+
context "when the pact version is not pending" do
|
57
|
+
its(:pending) { is_expected.to be false }
|
58
|
+
its(:pending_provider_tags) { is_expected.to eq [] }
|
59
|
+
its(:non_pending_provider_tags) { is_expected.to eq [] }
|
60
|
+
end
|
61
|
+
|
62
|
+
context "when the pact version is pending" do
|
63
|
+
let(:pending_1) { true }
|
64
|
+
its(:pending) { is_expected.to be true }
|
65
|
+
its(:pending_provider_tags) { is_expected.to eq [] }
|
66
|
+
its(:non_pending_provider_tags) { is_expected.to eq [] }
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context "when there are provider version tags" do
|
71
|
+
let(:provider_version_tags) { %w[dev feat-x] }
|
72
|
+
|
73
|
+
context "when a pact is pending for any of the provider tags" do
|
74
|
+
let(:pending_provider_version_tags) { %w[dev] }
|
75
|
+
|
76
|
+
its(:pending) { is_expected.to be true }
|
77
|
+
its(:pending_provider_tags) { is_expected.to eq %w[dev] }
|
78
|
+
its(:non_pending_provider_tags) { is_expected.to eq %w[feat-x] }
|
79
|
+
end
|
80
|
+
|
81
|
+
context "when a pact is not pending for any of the provider tags" do
|
82
|
+
let(:pending_provider_version_tags) { [] }
|
83
|
+
|
84
|
+
its(:pending) { is_expected.to be false }
|
85
|
+
its(:pending_provider_tags) { is_expected.to eq [] }
|
86
|
+
its(:non_pending_provider_tags) { is_expected.to eq %w[dev feat-x] }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'pact_broker/pacts/verifiable_pact_messages'
|
2
|
+
require 'pact_broker/pacts/verifiable_pact'
|
3
|
+
|
4
|
+
module PactBroker
|
5
|
+
module Pacts
|
6
|
+
describe VerifiablePactMessages do
|
7
|
+
let(:head_consumer_tags) { [] }
|
8
|
+
let(:pending_provider_tags) { [] }
|
9
|
+
let(:non_pending_provider_tags) { [] }
|
10
|
+
let(:pending) { false }
|
11
|
+
let(:verifiable_pact) do
|
12
|
+
double(VerifiablePact,
|
13
|
+
head_consumer_tags: head_consumer_tags,
|
14
|
+
consumer_name: "Foo",
|
15
|
+
provider_name: "Bar",
|
16
|
+
pending_provider_tags: pending_provider_tags,
|
17
|
+
non_pending_provider_tags: non_pending_provider_tags,
|
18
|
+
pending?: pending
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
subject { VerifiablePactMessages.new(verifiable_pact) }
|
23
|
+
|
24
|
+
describe "#inclusion_reason" do
|
25
|
+
context "when there are no head consumer tags" do
|
26
|
+
its(:inclusion_reason) { is_expected.to include "This pact is being verified because it is the latest pact between Foo and Bar." }
|
27
|
+
end
|
28
|
+
|
29
|
+
context "when there is 1 head consumer tags" do
|
30
|
+
let(:head_consumer_tags) { %w[dev] }
|
31
|
+
its(:inclusion_reason) { is_expected.to include "This pact is being verified because it is the pact for the latest version of Foo tagged with 'dev'" }
|
32
|
+
end
|
33
|
+
|
34
|
+
context "when there are 2 head consumer tags" do
|
35
|
+
let(:head_consumer_tags) { %w[dev prod] }
|
36
|
+
its(:inclusion_reason) { is_expected.to include "This pact is being verified because it is the pact for the latest versions of Foo tagged with 'dev' and 'prod' (both have the same content)" }
|
37
|
+
end
|
38
|
+
|
39
|
+
context "when there are 3 head consumer tags" do
|
40
|
+
let(:head_consumer_tags) { %w[dev prod feat-x] }
|
41
|
+
its(:inclusion_reason) { is_expected.to include "This pact is being verified because it is the pact for the latest versions of Foo tagged with 'dev', 'prod' and 'feat-x' (all have the same content)" }
|
42
|
+
end
|
43
|
+
|
44
|
+
context "when there are 4 head consumer tags" do
|
45
|
+
let(:head_consumer_tags) { %w[dev prod feat-x feat-y] }
|
46
|
+
its(:inclusion_reason) { is_expected.to include "'dev', 'prod', 'feat-x' and 'feat-y'" }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "#pending_reason" do
|
51
|
+
context "when the pact is not pending" do
|
52
|
+
context "when there are no non_pending_provider_tags" do
|
53
|
+
its(:pending_reason) { is_expected.to include "This pact has previously been successfully verified by Bar. If this verification fails, it will fail the build." }
|
54
|
+
end
|
55
|
+
|
56
|
+
context "when there is 1 non_pending_provider_tag" do
|
57
|
+
let(:non_pending_provider_tags) { %w[dev] }
|
58
|
+
|
59
|
+
its(:pending_reason) { is_expected.to include "This pact has previously been successfully verified by a version of Bar with tag 'dev'. If this verification fails, it will fail the build."}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context "when the pact is pending" do
|
64
|
+
let(:pending) { true }
|
65
|
+
|
66
|
+
context "when there are no pending_provider_tags" do
|
67
|
+
context "when there are no non_pending_provider_tags" do
|
68
|
+
its(:pending_reason) { is_expected.to include "This pact is in pending state because it has not yet been successfully verified by Bar. If this verification fails, it will not cause the overall build to fail." }
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context "when there is 1 pending_provider_tag" do
|
73
|
+
let(:pending_provider_tags) { %w[dev] }
|
74
|
+
|
75
|
+
its(:pending_reason) { is_expected.to include "This pact is in pending state because it has not yet been successfully verified by any version of Bar with tag 'dev'. If this verification fails, it will not cause the overall build to fail." }
|
76
|
+
end
|
77
|
+
|
78
|
+
context "when there are 2 pending_provider_tags" do
|
79
|
+
let(:pending_provider_tags) { %w[dev feat-x] }
|
80
|
+
|
81
|
+
its(:pending_reason) { is_expected.to include "This pact is in pending state because it has not yet been successfully verified by any versions of Bar with tag 'dev' and 'feat-x'." }
|
82
|
+
end
|
83
|
+
|
84
|
+
context "when there are 3 pending_provider_tags" do
|
85
|
+
let(:pending_provider_tags) { %w[dev feat-x feat-y] }
|
86
|
+
|
87
|
+
its(:pending_reason) { is_expected.to include "'dev', 'feat-x' and 'feat-y'" }
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
File without changes
|
@@ -28,10 +28,10 @@ module PactBroker
|
|
28
28
|
its(:consumer_group_url) { should eq "/groups/Consumer%20Name" }
|
29
29
|
its(:provider_group_url) { should eq "/groups/Provider%20Name" }
|
30
30
|
|
31
|
-
describe "
|
31
|
+
describe "pseudo_branch_verification_status" do
|
32
32
|
let(:domain_relationship) do
|
33
33
|
instance_double("PactBroker::Domain::IndexItem",
|
34
|
-
|
34
|
+
pseudo_branch_verification_status: pseudo_branch_verification_status,
|
35
35
|
provider_name: "Foo",
|
36
36
|
latest_verification_provider_version_number: "4.5.6")
|
37
37
|
end
|
@@ -42,29 +42,29 @@ module PactBroker
|
|
42
42
|
subject { IndexItem.new(domain_relationship) }
|
43
43
|
|
44
44
|
context "when the pact has never been verified" do
|
45
|
-
let(:
|
46
|
-
its(:
|
45
|
+
let(:pseudo_branch_verification_status) { :never }
|
46
|
+
its(:pseudo_branch_verification_status) { is_expected.to eq "" }
|
47
47
|
its(:warning?) { is_expected.to be false }
|
48
48
|
its(:verification_tooltip) { is_expected.to eq nil }
|
49
49
|
end
|
50
50
|
|
51
51
|
context "when the pact has changed since the last successful verification" do
|
52
|
-
let(:
|
53
|
-
its(:
|
52
|
+
let(:pseudo_branch_verification_status) { :stale }
|
53
|
+
its(:pseudo_branch_verification_status) { is_expected.to eq "warning" }
|
54
54
|
its(:warning?) { is_expected.to be true }
|
55
55
|
its(:verification_tooltip) { is_expected.to eq "Pact has changed since last successful verification by Foo (v4.5.6)" }
|
56
56
|
end
|
57
57
|
|
58
58
|
context "when the pact has not changed since the last successful verification" do
|
59
|
-
let(:
|
60
|
-
its(:
|
59
|
+
let(:pseudo_branch_verification_status) { :success }
|
60
|
+
its(:pseudo_branch_verification_status) { is_expected.to eq "success" }
|
61
61
|
its(:warning?) { is_expected.to be false }
|
62
62
|
its(:verification_tooltip) { is_expected.to eq "Successfully verified by Foo (v4.5.6)" }
|
63
63
|
end
|
64
64
|
|
65
65
|
context "when the pact verification failed" do
|
66
|
-
let(:
|
67
|
-
its(:
|
66
|
+
let(:pseudo_branch_verification_status) { :failed }
|
67
|
+
its(:pseudo_branch_verification_status) { is_expected.to eq "danger" }
|
68
68
|
its(:warning?) { is_expected.to be false }
|
69
69
|
its(:verification_tooltip) { is_expected.to eq "Verification by Foo (v4.5.6) failed" }
|
70
70
|
end
|
data/spec/lib/pact_broker/verifications/{verification_status_spec.rb → pseudo_branch_status_spec.rb}
RENAMED
@@ -1,9 +1,9 @@
|
|
1
|
-
require 'pact_broker/verifications/
|
1
|
+
require 'pact_broker/verifications/pseudo_branch_status'
|
2
2
|
|
3
3
|
module PactBroker
|
4
4
|
module Verifications
|
5
|
-
describe
|
6
|
-
describe "
|
5
|
+
describe PseudoBranchStatus do
|
6
|
+
describe "pseudo_branch_verification_status" do
|
7
7
|
|
8
8
|
let(:latest_verification) { instance_double("PactBroker::Domain::Verification", pact_version_sha: latest_verification_pact_version_sha, success: success) }
|
9
9
|
let(:latest_pact) { instance_double("PactBroker::Domain::Pact", pact_version_sha: pact_pact_version_sha) }
|
@@ -11,7 +11,7 @@ module PactBroker
|
|
11
11
|
let(:latest_verification_pact_version_sha) { '1234' }
|
12
12
|
let(:success) { true }
|
13
13
|
|
14
|
-
subject {
|
14
|
+
subject { PseudoBranchStatus.new(latest_pact, latest_verification) }
|
15
15
|
|
16
16
|
context "when the pact is nil (used in badge resource)" do
|
17
17
|
let(:latest_pact) { nil }
|
@@ -67,6 +67,12 @@ RSpec::Matchers.define :include_hash_matching do |expected|
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def slice actual, keys
|
70
|
-
keys.each_with_object({})
|
70
|
+
keys.each_with_object({}) do |k, hash|
|
71
|
+
if (actual.respond_to?(:has_key?) && actual.has_key?(k))
|
72
|
+
hash[k] = actual[k]
|
73
|
+
elsif actual.respond_to?(k)
|
74
|
+
hash[k] = actual.send(k)
|
75
|
+
end
|
76
|
+
end
|
71
77
|
end
|
72
78
|
end
|