Add test for listing interfaces with docker networks

This commit is contained in:
Brian Cain 2019-10-10 11:38:57 -07:00
parent 435a32684f
commit 7c93151f67
No known key found for this signature in database
GPG Key ID: 9FC4639B2E4510A0
1 changed files with 19 additions and 0 deletions

View File

@ -197,6 +197,25 @@ describe VagrantPlugins::DockerProvider::Action::PrepareNetworks do
end
end
describe "#list_interfaces" do
let(:interfaces){ ["192.168.1.2", "192.168.10.10"] }
it "returns an array of interfaces to use" do
allow(Socket).to receive(:getifaddrs).
and_return(interfaces.map{|i| double(:socket, addr: Addrinfo.ip(i))})
interfaces = subject.list_interfaces
expect(subject.list_interfaces.size).to eq(2)
end
it "does not include an interface with the address is nil" do
allow(Socket).to receive(:getifaddrs).
and_return(interfaces.map{|i| double(:socket, addr: nil)})
expect(subject.list_interfaces.size).to eq(0)
end
end
describe "#generate_create_cli_arguments" do
let(:network_options) {
{:ip=>"172.20.128.2",