-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
96 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
require 'spec_helper' | ||
require 'vagrant-cloudstack/action/read_ssh_info' | ||
require 'vagrant-cloudstack/config' | ||
|
||
describe VagrantPlugins::Cloudstack::Action::ReadSSHInfo do | ||
let(:action) { VagrantPlugins::Cloudstack::Action::ReadSSHInfo.new(nil, nil) } | ||
|
||
describe "#fetch_nic_ip_address" do | ||
subject { action.fetch_nic_ip_address(nics, domain_config) } | ||
|
||
let(:nics) do | ||
[ | ||
{ "networkid" => "networkid1", "networkname" => "networkname1", "ipaddress" => "127.0.0.1" }, | ||
{ "networkid" => "networkid2", "networkname" => "networkname2", "ipaddress" => "127.0.0.2" }, | ||
{ "networkid" => "networkid3", "networkname" => "networkname3", "ipaddress" => "127.0.0.3" }, | ||
] | ||
end | ||
|
||
let(:ssh_network_id) { Vagrant::Plugin::V2::Config::UNSET_VALUE } | ||
let(:ssh_network_name) { Vagrant::Plugin::V2::Config::UNSET_VALUE } | ||
|
||
let(:domain_config) do | ||
config = VagrantPlugins::Cloudstack::Config.new | ||
config.domain_config :cloudstack do |cloudstack| | ||
cloudstack.ssh_network_id = ssh_network_id | ||
cloudstack.ssh_network_name = ssh_network_name | ||
end | ||
config.finalize! | ||
config.get_domain_config(:cloudstack) | ||
end | ||
|
||
context "without neither ssh_network_id and ssh_network_name" do | ||
it { should eq "127.0.0.1" } | ||
end | ||
|
||
context "with ssh_network_id" do | ||
context "when exists in nics" do | ||
let(:ssh_network_id) { "networkid2" } | ||
|
||
it { should eq "127.0.0.2" } | ||
end | ||
|
||
context "when not exists in nics" do | ||
let(:ssh_network_id) { "unknown" } | ||
|
||
it { should eq "127.0.0.1" } | ||
end | ||
end | ||
|
||
context "with ssh_network_id" do | ||
context "when exists in nics" do | ||
let(:ssh_network_name) { "networkname3" } | ||
|
||
it { should eq "127.0.0.3" } | ||
end | ||
|
||
context "when not exists in nics" do | ||
let(:ssh_network_name) { "unknown" } | ||
|
||
it { should eq "127.0.0.1" } | ||
end | ||
end | ||
|
||
context "with both ssh_network_id and ssh_network_name" do | ||
context "when exists in nics" do | ||
let(:ssh_network_id) { "networkid2" } | ||
let(:ssh_network_name) { "networkname3" } | ||
|
||
it { should eq "127.0.0.2" } | ||
end | ||
|
||
context "when not exists in nics" do | ||
let(:ssh_network_id) { "unknown" } | ||
let(:ssh_network_name) { "unknown" } | ||
|
||
it { should eq "127.0.0.1" } | ||
end | ||
end | ||
end | ||
end |