From 36f2aaf55e34706689846d11220b5403810963dd Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Fri, 22 Mar 2019 08:45:14 -0700 Subject: [PATCH] Add test for public network gateway request --- .../docker/action/prepare_networks_test.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/unit/plugins/providers/docker/action/prepare_networks_test.rb b/test/unit/plugins/providers/docker/action/prepare_networks_test.rb index 22f2aae90..2b5b0fb4e 100644 --- a/test/unit/plugins/providers/docker/action/prepare_networks_test.rb +++ b/test/unit/plugins/providers/docker/action/prepare_networks_test.rb @@ -306,6 +306,19 @@ describe VagrantPlugins::DockerProvider::Action::PrepareNetworks do end describe "#request_public_gateway" 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.130.2", prefix: 22, succ: "172.30.130.3", + ipv6?: false) } + + it "requests a gateway" do + allow(IPAddr).to receive(:new).and_return(ipaddr) + allow(ipaddr).to receive(:include?).and_return(false) + allow(machine.ui).to receive(:ask).and_return("1") + + addr = subject.request_public_gateway(options, "bridge", env) + + expect(addr).to eq("172.30.130.2") + end end describe "#request_public_iprange" do