forked from ManageIQ/manageiq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ManageIQ#20759 from djberg96/better_check_connection
Add git remote connection check code
- Loading branch information
Showing
4 changed files
with
76 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -345,5 +345,49 @@ | |
end | ||
end | ||
end | ||
|
||
context "check_connection?" do | ||
require 'net/ping/external' | ||
let(:ext_ping) { instance_double(Net::Ping::External) } | ||
|
||
before do | ||
allow(Net::Ping::External).to receive(:new).and_return(ext_ping) | ||
allow(ext_ping).to receive(:exception) | ||
end | ||
|
||
it "returns true if it can ping the repo" do | ||
allow(ext_ping).to receive(:ping?).and_return(true) | ||
expect($log).to receive(:debug).with(/pinging '.*' to verify network connection/) | ||
expect(repo.check_connection?).to eq(true) | ||
end | ||
|
||
it "returns false if it cannot ping the repo" do | ||
allow(ext_ping).to receive(:ping?).and_return(false) | ||
expect($log).to receive(:debug).with(/pinging '.*' to verify network connection/) | ||
expect($log).to receive(:debug).with(/ping failed: .*/) | ||
expect(repo.check_connection?).to eq(false) | ||
end | ||
|
||
it "handles git urls without issue" do | ||
allow(repo).to receive(:url).and_return("[email protected]:ManageIQ/manageiq.git") | ||
allow(ext_ping).to receive(:ping?).and_return(true) | ||
expect($log).to receive(:debug).with(/pinging 'example.com' to verify network connection/) | ||
expect(repo.check_connection?).to eq(true) | ||
end | ||
|
||
it "handles ssh urls without issue" do | ||
allow(repo).to receive(:url).and_return("ssh://[email protected]:443/manageiq.git") | ||
allow(ext_ping).to receive(:ping?).and_return(true) | ||
expect($log).to receive(:debug).with(/pinging 'example.com' to verify network connection/) | ||
expect(repo.check_connection?).to eq(true) | ||
end | ||
|
||
it "handles file urls without issue" do | ||
allow(repo).to receive(:url).and_return("file://example.com/server/manageiq.git") | ||
allow(ext_ping).to receive(:ping?).and_return(true) | ||
expect($log).to receive(:debug).with(/pinging 'example.com' to verify network connection/) | ||
expect(repo.check_connection?).to eq(true) | ||
end | ||
end | ||
end | ||
end |