Sha256: d56ad66f6c616b6a4acfe1066bce98f24a42353708a5cd84147841376ada19ae

Contents?: true

Size: 1.64 KB

Versions: 6

Compression:

Stored size: 1.64 KB

Contents

require_relative "../../../../base"

describe "VagrantPlugins::GuestArch::Cap::ConfigureNetworks" do
  let(:described_class) do
    VagrantPlugins::GuestArch::Plugin
      .components
      .guest_capabilities[:arch]
      .get(:configure_networks)
  end

  let(:machine) { double("machine") }
  let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) }

  before do
    allow(machine).to receive(:communicate).and_return(comm)
    comm.stub_command("ip -o -0 addr | grep -v LOOPBACK | awk '{print $2}' | sed 's/://'",
      stdout: "eth1\neth2")
  end

  after do
    comm.verify_expectations!
  end

  describe ".configure_networks" do
    let(:network_1) do
      {
        interface: 0,
        type: "dhcp",
      }
    end

    let(:network_2) do
      {
        interface: 1,
        type: "static",
        ip: "33.33.33.10",
        netmask: "255.255.0.0",
        gateway: "33.33.0.1",
      }
    end

    it "creates and starts the networks" do
      described_class.configure_networks(machine, [network_1, network_2])
      expect(comm.received_commands[1]).to match(/mv (.+) '\/etc\/netctl\/eth1'/)
      expect(comm.received_commands[1]).to match(/ip link set 'eth1' down/)
      expect(comm.received_commands[1]).to match(/netctl restart 'eth1'/)
      expect(comm.received_commands[1]).to match(/netctl enable 'eth1'/)

      expect(comm.received_commands[1]).to match(/mv (.+) '\/etc\/netctl\/eth2'/)
      expect(comm.received_commands[1]).to match(/ip link set 'eth2' down/)
      expect(comm.received_commands[1]).to match(/netctl restart 'eth2'/)
      expect(comm.received_commands[1]).to match(/netctl enable 'eth2'/)
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/test/unit/plugins/guests/arch/cap/configure_networks_test.rb
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/test/unit/plugins/guests/arch/cap/configure_networks_test.rb
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/test/unit/plugins/guests/arch/cap/configure_networks_test.rb
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/test/unit/plugins/guests/arch/cap/configure_networks_test.rb
vagrant-unbundled-1.8.4.2 test/unit/plugins/guests/arch/cap/configure_networks_test.rb
vagrant-unbundled-1.8.4.1 test/unit/plugins/guests/arch/cap/configure_networks_test.rb