From 2bc6fa854ae9fdd31dedda00b7c3b94a79e4fcb8 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Thu, 21 Mar 2019 13:51:24 -0700 Subject: [PATCH] Add tests for validating network configurations --- .../docker/action/prepare_networks_test.rb | 16 ++++++++++++++++ 1 file changed, 16 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 caad13d10..ba903ed84 100644 --- a/test/unit/plugins/providers/docker/action/prepare_networks_test.rb +++ b/test/unit/plugins/providers/docker/action/prepare_networks_test.rb @@ -237,6 +237,22 @@ describe VagrantPlugins::DockerProvider::Action::PrepareNetworks do to be_truthy end + it "raises an error of the address is invalid" do + allow(driver).to receive(:network_containing_address).with(options[:ip]). + and_return("fakename") + expect{subject.validate_network_configuration!(netname, options, network_options, driver)}. + to raise_error(VagrantPlugins::DockerProvider::Errors::NetworkAddressInvalid) + end + + it "raises an error of the subnet is invalid" do + allow(driver).to receive(:network_containing_address).with(options[:ip]). + and_return(netname) + allow(driver).to receive(:network_containing_address).with(network_options[:subnet]). + and_return("fakename") + + expect{subject.validate_network_configuration!(netname, options, network_options, driver)}. + to raise_error(VagrantPlugins::DockerProvider::Errors::NetworkSubnetInvalid) + end end describe "#process_private_network" do