pact_broker 2.71.0 → 2.72.0
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/.github/workflows/test.yml +1 -21
- data/CHANGELOG.md +11 -0
- data/Dockerfile +5 -1
- data/docker-compose-ci-mysql.yml +37 -0
- data/lib/pact_broker/api/pact_broker_urls.rb +5 -1
- data/lib/pact_broker/api/resources/metadata_resource_methods.rb +23 -0
- data/lib/pact_broker/api/resources/pact.rb +2 -13
- data/lib/pact_broker/api/resources/pact_resource_methods.rb +23 -0
- data/lib/pact_broker/api/resources/pact_version.rb +3 -0
- data/lib/pact_broker/api/resources/tagged_pact_versions.rb +4 -0
- data/lib/pact_broker/api/resources/verifications.rb +2 -4
- data/lib/pact_broker/db/clean_incremental.rb +132 -22
- data/lib/pact_broker/db/delete_overwritten_data.rb +55 -27
- data/lib/pact_broker/domain/tag.rb +42 -0
- data/lib/pact_broker/domain/verification.rb +87 -0
- data/lib/pact_broker/metrics/service.rb +5 -3
- data/lib/pact_broker/pacts/all_pact_publications.rb +8 -0
- data/lib/pact_broker/pacts/repository.rb +35 -11
- data/lib/pact_broker/tasks/clean_task.rb +9 -3
- data/lib/pact_broker/tasks/delete_overwritten_data_task.rb +23 -7
- data/lib/pact_broker/test/test_data_builder.rb +24 -0
- data/lib/pact_broker/version.rb +1 -1
- data/script/docker-container/test.sh +3 -0
- data/script/docker/db-psql.sh +3 -0
- data/script/docker/db-reload.sh +11 -0
- data/script/pry.rb +25 -0
- data/script/seed.rb +1 -0
- data/script/test/run-rake-on-docker-compose-mysql.sh +8 -0
- data/spec/features/delete_tagged_pact_versions_spec.rb +2 -2
- data/spec/features/get_pact_spec.rb +2 -2
- data/spec/features/get_pact_version.rb +26 -3
- data/spec/fixtures/approvals/clean_incremental_dry_run.approved.json +100 -0
- data/spec/lib/pact_broker/api/pact_broker_urls_spec.rb +6 -0
- data/spec/lib/pact_broker/api/resources/pact_spec.rb +20 -9
- data/spec/lib/pact_broker/api/resources/tagged_pact_versions_spec.rb +10 -2
- data/spec/lib/pact_broker/api/resources/verifications_spec.rb +7 -3
- data/spec/lib/pact_broker/db/clean_incremental_spec.rb +9 -1
- data/spec/lib/pact_broker/db/delete_overwritten_data_spec.rb +71 -11
- data/spec/lib/pact_broker/domain/tag_spec.rb +23 -9
- data/spec/lib/pact_broker/domain/verification_spec.rb +49 -0
- data/spec/lib/pact_broker/metrics/service_spec.rb +4 -1
- data/spec/lib/pact_broker/pacts/repository_spec.rb +54 -7
- data/spec/migrations/change_migration_strategy_spec.rb +1 -1
- metadata +12 -2
@@ -18,15 +18,29 @@ module PactBroker
|
|
18
18
|
.create_consumer_version_tag("test")
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
pacticipant
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
21
|
+
describe "#latest_tags_for_pacticipant_ids" do
|
22
|
+
it "returns the latest tags for the given pacticipant ids" do
|
23
|
+
pacticipant = PactBroker::Domain::Pacticipant.order(:id).first
|
24
|
+
tags = Tag.latest_tags_for_pacticipant_ids([pacticipant.id]).all
|
25
|
+
expect(tags.collect(&:name).sort).to eq %w{bloop dev prod}
|
26
|
+
expect(tags.find{ |t| t.name == "dev" }.version.number).to eq "3"
|
27
|
+
expect(tags.find{ |t| t.name == "prod" }.version.number).to eq "1"
|
28
|
+
expect(tags.find{ |t| t.name == "bloop" }.version.number).to eq "2"
|
29
|
+
expect(tags.collect(&:version_id).compact.size).to eq 3
|
30
|
+
expect(tags.collect(&:created_at).compact.size).to eq 3
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "latest_tags" do
|
35
|
+
it "returns the tags that belong to the most recent version with that tag/pacticipant" do
|
36
|
+
tags = Tag.latest_tags.all
|
37
|
+
expect(tags.collect(&:name).sort).to eq %w{bloop dev prod test}
|
38
|
+
expect(tags.find{ |t| t.name == "dev" }.version.number).to eq "3"
|
39
|
+
expect(tags.find{ |t| t.name == "prod" }.version.number).to eq "1"
|
40
|
+
expect(tags.find{ |t| t.name == "bloop" }.version.number).to eq "2"
|
41
|
+
expect(tags.collect(&:version_id).compact.size).to eq 4
|
42
|
+
expect(tags.collect(&:created_at).compact.size).to eq 4
|
43
|
+
end
|
30
44
|
end
|
31
45
|
end
|
32
46
|
end
|
@@ -4,6 +4,55 @@ module PactBroker
|
|
4
4
|
|
5
5
|
module Domain
|
6
6
|
describe Verification do
|
7
|
+
describe "latest_verifications_for_all_consumer_version_tags" do
|
8
|
+
before do
|
9
|
+
td.create_pact_with_verification_and_tags("Foo", "1", ["fmain"], "Bar", "2")
|
10
|
+
.create_pact_with_verification_and_tags("Foo", "3", ["fmain"], "Bar", "4")
|
11
|
+
.create_pact_with_verification_and_tags("Foo", "5", ["fmain"], "Bar", "5")
|
12
|
+
.create_pact_with_verification_and_tags("Foo", "6", ["other"], "Bar", "5")
|
13
|
+
.create_pact_with_verification_and_tags("Foo2", "6", ["fprod"], "Bar", "7")
|
14
|
+
.create_pact_with_verification_and_tags("Ignored", "6", ["fmain"], "Bar", "8")
|
15
|
+
end
|
16
|
+
|
17
|
+
subject { Verification.latest_verifications_for_all_consumer_version_tags.all }
|
18
|
+
|
19
|
+
it "returns the same number of rows as the view" do
|
20
|
+
expect(subject.size).to eq Verification.db[:latest_verifications_for_consumer_version_tags].count
|
21
|
+
end
|
22
|
+
|
23
|
+
it "allows eager" do
|
24
|
+
expect(Verification.latest_verifications_for_all_consumer_version_tags.eager(:provider_version).all.first.provider_version.number).to_not be nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "latest_verifications_for_consumer_version_tags" do
|
29
|
+
before do
|
30
|
+
td.create_pact_with_verification_and_tags("Foo", "1", ["fmain"], "Bar", "2")
|
31
|
+
.create_pact_with_verification_and_tags("Foo", "3", ["fmain"], "Bar", "4")
|
32
|
+
.create_pact_with_verification_and_tags("Foo", "5", ["fmain"], "Bar", "5")
|
33
|
+
.create_pact_with_verification_and_tags("Foo", "6", ["other"], "Bar", "5")
|
34
|
+
.create_pact_with_verification_and_tags("Foo2", "6", ["fprod"], "Bar", "7")
|
35
|
+
.create_pact_with_verification_and_tags("Ignored", "6", ["fmain"], "Bar", "8")
|
36
|
+
end
|
37
|
+
|
38
|
+
let(:consumer_ids) { PactBroker::Domain::Pacticipant.where(name: ["Foo", "Foo2"]).all.collect(&:id) }
|
39
|
+
|
40
|
+
subject { Verification.latest_verifications_for_consumer_version_tags(consumer_ids, ["fmain", "fprod"]).order(:id) }
|
41
|
+
|
42
|
+
it "returns the latest verifications for the given consumer ids and consumer version tag names" do
|
43
|
+
expect(subject.first.provider_version_number).to eq "5"
|
44
|
+
expect(subject.first.consumer_name).to eq "Foo"
|
45
|
+
expect(subject.first.consumer_version_tag_name).to eq "fmain"
|
46
|
+
expect(subject.last.provider_version_number).to eq "7"
|
47
|
+
expect(subject.last.consumer_name).to eq "Foo2"
|
48
|
+
expect(subject.last.consumer_version_tag_name).to eq "fprod"
|
49
|
+
end
|
50
|
+
|
51
|
+
it "allows eager" do
|
52
|
+
expect(subject.eager(:provider_version).all.first.provider_version.number).to eq "5"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
7
56
|
describe "delete" do
|
8
57
|
before do
|
9
58
|
td.create_pact_with_hierarchy("Foo", "1", "Bar")
|
@@ -9,17 +9,20 @@ module PactBroker
|
|
9
9
|
describe "verificationResultsPerPactVersion" do
|
10
10
|
before do
|
11
11
|
td.create_pact_with_hierarchy
|
12
|
+
.create_consumer_version_tag("prod")
|
12
13
|
.comment("this pact version will have 2 verifications")
|
13
14
|
.create_verification
|
14
|
-
.create_verification(number: 2)
|
15
|
+
.create_verification(number: 2, tag_names: ["main"])
|
15
16
|
.revise_pact
|
16
17
|
.comment("this pact version will have 1 verification")
|
17
18
|
.create_verification
|
18
19
|
.create_consumer_version
|
20
|
+
.create_consumer_version_tag("main")
|
19
21
|
.create_pact
|
20
22
|
.comment("this pact will have 1 verification")
|
21
23
|
.create_verification
|
22
24
|
.create_consumer_version
|
25
|
+
.create_consumer_version_tag("main")
|
23
26
|
.create_pact
|
24
27
|
.comment("this pact will have 1 verification")
|
25
28
|
.create_verification
|
@@ -569,8 +569,7 @@ module PactBroker
|
|
569
569
|
|
570
570
|
describe "find_pact" do
|
571
571
|
let!(:pact) do
|
572
|
-
|
573
|
-
pact = builder
|
572
|
+
pact = td
|
574
573
|
.create_consumer("Consumer")
|
575
574
|
.create_consumer_version("1.2.2")
|
576
575
|
.create_provider("Provider")
|
@@ -580,7 +579,7 @@ module PactBroker
|
|
580
579
|
.create_pact
|
581
580
|
.revise_pact
|
582
581
|
.and_return(:pact)
|
583
|
-
|
582
|
+
td
|
584
583
|
.create_consumer_version("1.2.6")
|
585
584
|
.create_pact
|
586
585
|
.create_provider("Another Provider")
|
@@ -600,6 +599,14 @@ module PactBroker
|
|
600
599
|
expect(subject.json_content).to_not be_nil
|
601
600
|
end
|
602
601
|
|
602
|
+
context "with no version" do
|
603
|
+
subject { Repository.new.find_pact("Consumer", nil, "Provider") }
|
604
|
+
|
605
|
+
it "returns the latest pact" do
|
606
|
+
expect(subject.consumer_version_number).to eq "1.2.6"
|
607
|
+
end
|
608
|
+
end
|
609
|
+
|
603
610
|
context "with a pact_version_sha" do
|
604
611
|
subject { Repository.new.find_pact "Consumer", nil, "Provider", pact.pact_version_sha }
|
605
612
|
|
@@ -609,26 +616,66 @@ module PactBroker
|
|
609
616
|
expect(subject.provider.name).to eq "Provider"
|
610
617
|
expect(subject.consumer_version_number).to eq "1.2.4"
|
611
618
|
expect(subject.revision_number).to eq 2
|
612
|
-
|
613
619
|
end
|
620
|
+
|
614
621
|
context "when there are multiple pact publications for the pact version" do
|
615
622
|
before do
|
616
623
|
# Double check the data is set up correctly...
|
617
624
|
expect(pact_1.pact_version_sha).to eq(pact_2.pact_version_sha)
|
618
625
|
end
|
619
626
|
|
620
|
-
let(:td) { TestDataBuilder.new }
|
621
627
|
let!(:pact_1) { td.create_pact_with_hierarchy("Foo", "1", "Bar").and_return(:pact) }
|
622
628
|
let!(:pact_2) { td.create_consumer_version("2").create_pact(json_content: pact_1.json_content).and_return(:pact) }
|
623
629
|
|
624
|
-
|
630
|
+
let(:consumer_version_number) { nil }
|
631
|
+
|
632
|
+
subject { Repository.new.find_pact "Foo", consumer_version_number, "Bar", pact_1.pact_version_sha }
|
625
633
|
|
626
634
|
it "returns the latest pact, ordered by consumer version order" do
|
627
635
|
expect(subject.consumer_version_number).to eq "2"
|
628
636
|
end
|
637
|
+
|
638
|
+
context "when the consumer_version_number is specified too (from the URL metadata)" do
|
639
|
+
let(:consumer_version_number) { "1" }
|
640
|
+
|
641
|
+
it "returns the publication with the consumer version specified" do
|
642
|
+
expect(subject.consumer_version_number).to eq "1"
|
643
|
+
end
|
644
|
+
end
|
645
|
+
|
646
|
+
context "when the consumer_version_number is specified too (from the URL metadata) but it doesn't exist (anymore)" do
|
647
|
+
let(:consumer_version_number) { "9" }
|
648
|
+
|
649
|
+
it "returns the pact matching the sha with the latest consumer version" do
|
650
|
+
expect(subject.consumer_version_number).to eq "2"
|
651
|
+
end
|
652
|
+
end
|
653
|
+
|
654
|
+
# Not sure when this would happen
|
655
|
+
context "when the consumer_version_number is specified too (from the URL metadata) and it exists but it doesn't match the sha" do
|
656
|
+
before do
|
657
|
+
td.create_pact_with_hierarchy("Foo", "8", "Bar")
|
658
|
+
end
|
659
|
+
|
660
|
+
let(:consumer_version_number) { "8" }
|
661
|
+
|
662
|
+
it "returns the pact matching the sha with the latest consumer version" do
|
663
|
+
expect(subject.consumer_version_number).to eq "2"
|
664
|
+
end
|
665
|
+
end
|
666
|
+
|
667
|
+
context "when the pact has multiple revisions and goes back to a previous revision" do
|
668
|
+
before do
|
669
|
+
td.revise_pact
|
670
|
+
.revise_pact(pact_1.json_content)
|
671
|
+
end
|
672
|
+
|
673
|
+
it "returns the latest revision" do
|
674
|
+
expect(subject.revision_number).to eq 3
|
675
|
+
end
|
676
|
+
end
|
629
677
|
end
|
630
678
|
end
|
631
|
-
|
632
679
|
end
|
633
680
|
|
634
681
|
describe "find_all_revisions" do
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
|
3
|
-
describe "changing from integer to timestamp migrations", no_db_clean: true do
|
3
|
+
describe "changing from integer to timestamp migrations", no_db_clean: true, skip: DB.mysql? do
|
4
4
|
|
5
5
|
TEST_DIR = "db/test/change_migration_strategy"
|
6
6
|
DATABASE_PATH = "#{TEST_DIR}/pact_broker_database.sqlite3"
|
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.
|
4
|
+
version: 2.72.0
|
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: 2020-
|
13
|
+
date: 2020-12-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: httparty
|
@@ -558,6 +558,7 @@ files:
|
|
558
558
|
- db/test/backwards_compatibility/spec/support/request_helpers.rb
|
559
559
|
- db/test/change_migration_strategy/Rakefile
|
560
560
|
- db/test/change_migration_strategy/before/Gemfile
|
561
|
+
- docker-compose-ci-mysql.yml
|
561
562
|
- docker-compose-dev-postgres.yml
|
562
563
|
- docker-compose-issue-repro.yml
|
563
564
|
- docker-compose-test.yml
|
@@ -675,9 +676,11 @@ files:
|
|
675
676
|
- lib/pact_broker/api/resources/matrix.rb
|
676
677
|
- lib/pact_broker/api/resources/matrix_badge.rb
|
677
678
|
- lib/pact_broker/api/resources/matrix_for_consumer_and_provider.rb
|
679
|
+
- lib/pact_broker/api/resources/metadata_resource_methods.rb
|
678
680
|
- lib/pact_broker/api/resources/metrics.rb
|
679
681
|
- lib/pact_broker/api/resources/pact.rb
|
680
682
|
- lib/pact_broker/api/resources/pact_content_diff.rb
|
683
|
+
- lib/pact_broker/api/resources/pact_resource_methods.rb
|
681
684
|
- lib/pact_broker/api/resources/pact_triggered_webhooks.rb
|
682
685
|
- lib/pact_broker/api/resources/pact_version.rb
|
683
686
|
- lib/pact_broker/api/resources/pact_versions.rb
|
@@ -1020,7 +1023,10 @@ files:
|
|
1020
1023
|
- public/stylesheets/matrix.css
|
1021
1024
|
- public/stylesheets/pact.css
|
1022
1025
|
- script/db-spec.sh
|
1026
|
+
- script/docker-container/test.sh
|
1023
1027
|
- script/docker/db-execute-sql-file.sh
|
1028
|
+
- script/docker/db-psql.sh
|
1029
|
+
- script/docker/db-reload.sh
|
1024
1030
|
- script/docker/db-restore.sh
|
1025
1031
|
- script/docker/db-rm.sh
|
1026
1032
|
- script/docker/db-start.sh
|
@@ -1036,6 +1042,7 @@ files:
|
|
1036
1042
|
- script/prod/clean-up.sql
|
1037
1043
|
- script/prod/migrate-latest-pacts.sh
|
1038
1044
|
- script/prod/redact-data.sql
|
1045
|
+
- script/pry.rb
|
1039
1046
|
- script/publish-2.sh
|
1040
1047
|
- script/publish-new.sh
|
1041
1048
|
- script/publish-not-a-pact.sh
|
@@ -1055,6 +1062,7 @@ files:
|
|
1055
1062
|
- script/seed-for-webhook-test.rb
|
1056
1063
|
- script/seed-matrix.rb
|
1057
1064
|
- script/seed.rb
|
1065
|
+
- script/test/run-rake-on-docker-compose-mysql.sh
|
1058
1066
|
- script/trigger-release.sh
|
1059
1067
|
- script/update-hal-browser
|
1060
1068
|
- script/watch.sh
|
@@ -1119,6 +1127,7 @@ files:
|
|
1119
1127
|
- spec/fixtures/a_consumer-a_provider-conflict.json
|
1120
1128
|
- spec/fixtures/a_consumer-a_provider-merged.json
|
1121
1129
|
- spec/fixtures/a_consumer-a_provider.json
|
1130
|
+
- spec/fixtures/approvals/clean_incremental_dry_run.approved.json
|
1122
1131
|
- spec/fixtures/approvals/modifiable_resources.approved.json
|
1123
1132
|
- spec/fixtures/certificate-invalid.pem
|
1124
1133
|
- spec/fixtures/certificate.pem
|
@@ -1516,6 +1525,7 @@ test_files:
|
|
1516
1525
|
- spec/fixtures/a_consumer-a_provider-conflict.json
|
1517
1526
|
- spec/fixtures/a_consumer-a_provider-merged.json
|
1518
1527
|
- spec/fixtures/a_consumer-a_provider.json
|
1528
|
+
- spec/fixtures/approvals/clean_incremental_dry_run.approved.json
|
1519
1529
|
- spec/fixtures/approvals/modifiable_resources.approved.json
|
1520
1530
|
- spec/fixtures/certificate-invalid.pem
|
1521
1531
|
- spec/fixtures/certificate.pem
|