Add test for requesting public ip range for docker network provider

This commit is contained in:
Brian Cain 2019-03-22 09:02:40 -07:00
parent 36f2aaf55e
commit 4f80a9e6d5
No known key found for this signature in database
GPG Key ID: 9FC4639B2E4510A0
2 changed files with 15 additions and 0 deletions

View File

@ -282,6 +282,7 @@ module VagrantPlugins
begin begin
range = IPAddr.new(range) range = IPAddr.new(range)
if !subnet.include?(range) if !subnet.include?(range)
puts "we in here"
env[:ui].warn(I18n.t( env[:ui].warn(I18n.t(
"docker_provider.network_bridge_iprange_outofbounds", "docker_provider.network_bridge_iprange_outofbounds",
subnet: network_options[:subnet], subnet: network_options[:subnet],

View File

@ -322,5 +322,19 @@ describe VagrantPlugins::DockerProvider::Action::PrepareNetworks do
end end
describe "#request_public_iprange" do describe "#request_public_iprange" do
let(:options) { {:ip=>"172.30.130.2", :subnet=>"172.30.0.0/16", :driver=>"bridge", :id=>"30e017d5-488f-5a2f-a3ke-k8dce8246b60"} }
let(:ipaddr) { double("ipaddr", to_s: "172.30.100.2", prefix: 22, succ: "172.30.100.3",
ipv6?: false) }
let(:subnet) { double("ipaddr", to_s: "172.30.130.2", prefix: 22, succ: "172.30.130.3",
ipv6?: false) }
it "requests a public ip range" do
allow(IPAddr).to receive(:new).with(options[:subnet]).and_return(subnet)
allow(IPAddr).to receive(:new).with("172.30.130.2").and_return(ipaddr)
allow(subnet).to receive(:include?).and_return(true)
allow(machine.ui).to receive(:ask).and_return(options[:ip])
addr = subject.request_public_iprange(options, "bridge", env)
end
end end
end end