-
-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: improve performance of network diagram (#614)
* fix: improve performance of network diagram Also cap the number of pacticipants that are included in the network diagram for performance and readability reasons PACT-1070
- Loading branch information
Showing
13 changed files
with
135 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,10 @@ def blank? | |
end | ||
|
||
refine String do | ||
def integer? | ||
self =~ /^\d+$/ | ||
end | ||
|
||
def present? | ||
!blank? | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,57 @@ | ||
require "spec_helper" | ||
require "pact_broker/groups/service" | ||
require "pact_broker/index/service" | ||
|
||
module PactBroker | ||
|
||
module Groups | ||
describe Service do | ||
|
||
describe "#find_group_containing" do | ||
before do | ||
td.create_consumer("app a") | ||
.create_provider("app x") | ||
.create_integration | ||
.create_consumer("app b") | ||
.create_provider("app y") | ||
.create_integration | ||
.use_consumer("app y") | ||
.create_provider("app z") | ||
.create_integration | ||
.use_consumer("app z") | ||
.use_provider("app y") | ||
.create_integration | ||
end | ||
|
||
let(:consumer_a) { double("consumer a", name: "consumer a", id: 1)} | ||
let(:consumer_b) { double("consumer b", name: "consumer b", id: 2)} | ||
let(:app_a) { td.find_pacticipant("app a") } | ||
let(:app_b) { td.find_pacticipant("app b") } | ||
|
||
let(:provider_x) { double("provider x", name: "provider x", id: 3)} | ||
let(:provider_y) { double("provider y", name: "provider y", id: 4)} | ||
let(:app_x) { td.find_pacticipant("app x") } | ||
let(:app_y) { td.find_pacticipant("app y") } | ||
let(:app_z) { td.find_pacticipant("app z") } | ||
|
||
let(:relationship_1) { Domain::IndexItem.new(consumer_a, provider_x) } | ||
let(:relationship_2) { Domain::IndexItem.new(consumer_b, provider_y) } | ||
let(:relationship_1) { Domain::IndexItem.new(app_a, app_x) } | ||
let(:relationship_2) { Domain::IndexItem.new(app_b, app_y) } | ||
let(:relationship_3) { Domain::IndexItem.new(app_y, app_z) } | ||
let(:relationship_3) { Domain::IndexItem.new(app_z, app_y) } | ||
|
||
let(:group_1) { Domain::Group.new(relationship_1) } | ||
let(:group_2) { Domain::Group.new(relationship_2) } | ||
let(:group_2) { Domain::Group.new(relationship_2, relationship_3) } | ||
|
||
let(:relationship_list) { double("relationship list") } | ||
let(:groups) { [group_1, group_2]} | ||
subject { Service.find_group_containing(app_b) } | ||
|
||
subject { Service.find_group_containing(consumer_b) } | ||
|
||
before do | ||
allow(PactBroker::Index::Service).to receive(:find_index_items).and_return(relationship_list) | ||
allow(Relationships::Groupify).to receive(:call).and_return(groups) | ||
end | ||
|
||
it "retrieves a list of the relationships" do | ||
allow(Index::Service).to receive(:find_index_items) | ||
subject | ||
it "returns the Group containing the given pacticipant" do | ||
expect(subject.size).to eq 3 | ||
expect(subject).to include(have_attributes(consumer_name: "app b", provider_name: "app y")) | ||
expect(subject).to include(have_attributes(consumer_name: "app y", provider_name: "app z")) | ||
expect(subject).to include(have_attributes(consumer_name: "app z", provider_name: "app y")) | ||
end | ||
|
||
it "turns the relationships into groups" do | ||
expect(Relationships::Groupify).to receive(:call).with(relationship_list) | ||
subject | ||
end | ||
context "when a max_pacticipants is specified" do | ||
subject { Service.find_group_containing(app_b, max_pacticipants: 2) } | ||
|
||
it "returns the Group containing the given pacticipant" do | ||
expect(subject).to be group_2 | ||
it "stops searching before reaching the end of the group" do | ||
expect(subject.size).to eq 1 | ||
expect(subject).to include(have_attributes(consumer_name: "app b", provider_name: "app y")) | ||
end | ||
end | ||
|
||
end | ||
|
||
end | ||
end | ||
end |
Oops, something went wrong.