Add public network tests for docker provider

This commit is contained in:
Brian Cain 2019-03-21 16:06:11 -07:00
parent 82700d95b3
commit 88a18fe2c5
No known key found for this signature in database
GPG Key ID: 9FC4639B2E4510A0
3 changed files with 22 additions and 0 deletions

View File

@ -69,6 +69,10 @@ module VagrantPlugins
error_key(:network_name_undefined)
end
class NetworkNoInterfaces < DockerError
error_key(:network_no_interfaces)
end
class PackageNotSupported < DockerError
error_key(:package_not_supported)
end

View File

@ -252,6 +252,9 @@ en:
The Docker provider was unable to configure networking using the
provided network name `%{network_name}`. Please ensure the network
name is correct and exists, then try again.
network_no_interfaces: |-
The Docker provider was unable to list any available interfaces to bridge
the public network with.
network_subnet_invalid: |-
The configured network subnet is not valid for the defined network.
Please update the network settings and try again.

View File

@ -281,6 +281,21 @@ describe VagrantPlugins::DockerProvider::Action::PrepareNetworks do
end
describe "#process_public_network" do
let(:options) { {:ip=>"172.30.130.2", :subnet=>"172.30.0.0/16", :driver=>"bridge", :id=>"30e017d5-488f-5a2f-a3ke-k8dce8246b60"} }
it "raises an error if there are no network interfaces" do
expect(subject).to receive(:list_interfaces).and_return([])
expect{subject.process_public_network(options, {}, env)}.
to raise_error(VagrantPlugins::DockerProvider::Errors::NetworkNoInterfaces)
end
it "generates a network name and configuration" do
allow(machine.ui).to receive(:ask).and_return("1")
network_name, network_options = subject.process_public_network(options, {}, env)
expect(network_name).to eq("vagrant_network_public")
end
end
describe "#request_public_gateway" do