From 6ce453ab70ea22127114e09c45f9c439638c96bc Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Thu, 21 Mar 2019 11:16:26 -0700 Subject: [PATCH] Delete old file and add blank describe blocks for remaining tests --- .../docker/action/connect_networks_test.rb | 150 ------------------ .../docker/action/prepare_networks_test.rb | 21 +++ 2 files changed, 21 insertions(+), 150 deletions(-) delete mode 100644 test/unit/plugins/providers/docker/action/connect_networks_test.rb diff --git a/test/unit/plugins/providers/docker/action/connect_networks_test.rb b/test/unit/plugins/providers/docker/action/connect_networks_test.rb deleted file mode 100644 index 5e5ea798b..000000000 --- a/test/unit/plugins/providers/docker/action/connect_networks_test.rb +++ /dev/null @@ -1,150 +0,0 @@ -require_relative "../../../../base" -require_relative "../../../../../../plugins/providers/docker/action/connect_networks" - -describe VagrantPlugins::DockerProvider::Action::ConnectNetworks do - include_context "unit" - include_context "virtualbox" - - let(:sandbox) { isolated_environment } - - let(:iso_env) do - # We have to create a Vagrantfile so there is a root path - sandbox.vagrantfile("") - sandbox.create_vagrant_env - end - - let(:machine) do - iso_env.machine(iso_env.machine_names[0], :docker).tap do |m| - allow(m.provider).to receive(:driver).and_return(driver) - allow(m.config.vm).to receive(:networks).and_return(networks) - end - end - - let(:env) {{ machine: machine, ui: machine.ui, root_path: Pathname.new(".") }} - let(:app) { lambda { |*args| }} - let(:driver) { double("driver", create: "abcd1234") } - - let(:networks) { [[:private_network, - {:ip=>"172.20.128.2", - :subnet=>"172.20.0.0/16", - :driver=>"bridge", - :internal=>"true", - :alias=>"mynetwork", - :protocol=>"tcp", - :id=>"80e017d5-388f-4a2f-a3de-f8dce8156a58"}], - [:private_network, - {:type=>"dhcp", - :ipv6=>"true", - :subnet=>"2a02:6b8:b010:9020:1::/80", - :protocol=>"tcp", - :id=>"b8f23054-38d5-45c3-99ea-d33fc5d1b9f2"}], - [:forwarded_port, - {:guest=>22, :host=>2200, :host_ip=>"127.0.0.1", :id=>"ssh", :auto_correct=>true, :protocol=>"tcp"}]] - } - - let(:invalid_network) { - [[:private_network, - {:ipv6=>"true", - :protocol=>"tcp", - :id=>"b8f23054-38d5-45c3-99ea-d33fc5d1b9f2"}]] - } - - subject { described_class.new(app, env) } - - after do - sandbox.close - end - - describe "#call" do - it "calls the next action in the chain" do - allow(driver).to receive(:host_vm?).and_return(false) - allow(driver).to receive(:existing_network?).and_return(false) - allow(driver).to receive(:create_network).and_return(true) - allow(driver).to receive(:connect_network).and_return(true) - allow(driver).to receive(:subnet_defined?).and_return(nil) - - called = false - app = ->(*args) { called = true } - - action = described_class.new(app, env) - action.call(env) - - expect(called).to eq(true) - end - - it "calls the proper driver methods to setup a network" do - allow(driver).to receive(:host_vm?).and_return(false) - allow(driver).to receive(:existing_network?).and_return(false) - allow(driver).to receive(:create_network).and_return(true) - allow(driver).to receive(:connect_network).and_return(true) - allow(driver).to receive(:subnet_defined?).and_return(nil) - - - expect(subject).to receive(:generate_create_cli_arguments). - with(networks[0][1]).and_return(["--subnet=172.20.0.0/16", "--driver=bridge", "--internal=true"]) - expect(subject).to receive(:generate_create_cli_arguments). - with(networks[1][1]).and_return(["--ipv6=true", "--subnet=2a02:6b8:b010:9020:1::/80"]) - expect(subject).to receive(:generate_connect_cli_arguments). - with(networks[0][1]).and_return(["--ipv6=true", "--subnet=2a02:6b8:b010:9020:1::/80"]) - expect(subject).to receive(:generate_connect_cli_arguments). - with(networks[1][1]).and_return([]) - - expect(driver).to receive(:create_network).twice - expect(driver).to receive(:connect_network).twice - - subject.call(env) - end - - it "uses an existing network if a matching subnet is found" do - allow(driver).to receive(:host_vm?).and_return(false) - allow(driver).to receive(:existing_network?).and_return(true) - allow(driver).to receive(:create_network).and_return(true) - allow(driver).to receive(:connect_network).and_return(true) - allow(driver).to receive(:subnet_defined?).and_return("my_cool_subnet_network") - - expect(driver).not_to receive(:create_network) - - subject.call(env) - end - - it "raises an error if an inproper network configuration is given" do - allow(machine.config.vm).to receive(:networks).and_return(invalid_network) - allow(driver).to receive(:host_vm?).and_return(false) - allow(driver).to receive(:existing_network?).and_return(false) - - expect{ subject.call(env) }.to raise_error(VagrantPlugins::DockerProvider::Errors::NetworkInvalidOption) - end - end - - describe "#generate_connect_cli_arguments" do - let(:network_options) { - {:ip=>"172.20.128.2", - :subnet=>"172.20.0.0/16", - :driver=>"bridge", - :internal=>"true", - :alias=>"mynetwork", - :protocol=>"tcp", - :id=>"80e017d5-388f-4a2f-a3de-f8dce8156a58"} } - - it "returns an array of cli arguments" do - cli_args = subject.generate_connect_cli_arguments(network_options) - expect(cli_args).to eq(["--ip", "172.20.128.2", "--alias=mynetwork"]) - end - end - - describe "#generate_create_cli_arguments" do - let(:network_options) { - {:ip=>"172.20.128.2", - :subnet=>"172.20.0.0/16", - :driver=>"bridge", - :internal=>"true", - :alias=>"mynetwork", - :protocol=>"tcp", - :id=>"80e017d5-388f-4a2f-a3de-f8dce8156a58"} } - - it "returns an array of cli arguments" do - cli_args = subject.generate_create_cli_arguments(network_options) - expect(cli_args).to eq(["--subnet=172.20.0.0/16", "--driver=bridge", "--internal=true"]) - end - end -end 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 84b5c829c..1932aabf8 100644 --- a/test/unit/plugins/providers/docker/action/prepare_networks_test.rb +++ b/test/unit/plugins/providers/docker/action/prepare_networks_test.rb @@ -192,4 +192,25 @@ describe VagrantPlugins::DockerProvider::Action::PrepareNetworks do expect(cli_args).to eq( ["--ip", "172.20.128.2", "--subnet", "172.20.0.0/16", "--driver", "bridge", "--alias", "mynetwork", "--protocol", "tcp", "--id", "80e017d5-388f-4a2f-a3de-f8dce8156a58"]) end end + + describe "#list_interfaces" do + end + + describe "#validate_network_name!" do + end + + describe "#validate_network_configuration!" do + end + + describe "#process_private_network" do + end + + describe "#process_public_network" do + end + + describe "#request_public_gateway" do + end + + describe "#request_public_iprange" do + end end