Sha256: 782545fe60864163fc0373e805162cad6bd2e779d72874b015c0e172366065d7

Contents?: true

Size: 1.21 KB

Versions: 81

Compression:

Stored size: 1.21 KB

Contents

require "test_helper"

class DestroyUnusedNetworkInterfacesVMActionTest < Test::Unit::TestCase
  setup do
    @klass = Vagrant::Action::VM::DestroyUnusedNetworkInterfaces
    @app, @env = action_env

    @vm = mock("vm")
    @env["vm"] = @vm

    @internal_vm = mock("internal")
    @vm.stubs(:vm).returns(@internal_vm)

    @instance = @klass.new(@app, @env)
  end

  context "calling" do
    setup do
      @interfaces = []
      global = mock("global")
      host = mock("host")
      VirtualBox::Global.stubs(:global).returns(global)
      global.stubs(:host).returns(host)
      host.stubs(:network_interfaces).returns(@interfaces)
    end

    def stub_interface(length=5, type=:host_only)
      interface = mock("interface")
      interface.stubs(:interface_type).returns(type)
      interface.stubs(:attached_vms).returns(Array.new(length))

      @interfaces << interface
      interface
    end

    should "destroy only the unused network interfaces" do
      stub_interface(5)
      stub_interface(7)
      results = [stub_interface(0), stub_interface(0)]

      results.each do |result|
        result.expects(:destroy).once
      end

      @app.expects(:call).with(@env).once
      @instance.call(@env)
    end
  end
end

Version data entries

81 entries across 81 versions & 9 rubygems

Version Path
bmhatfield-vagrant-1.0.10 test/unit_legacy/vagrant/action/vm/destroy_unused_network_interfaces_test.rb
bmhatfield-vagrant-1.0.9 test/unit_legacy/vagrant/action/vm/destroy_unused_network_interfaces_test.rb
bmhatfield-vagrant-1.0.8 test/unit_legacy/vagrant/action/vm/destroy_unused_network_interfaces_test.rb
bmhatfield-vagrant-1.0.7 test/unit_legacy/vagrant/action/vm/destroy_unused_network_interfaces_test.rb
vagrantup-1.0.7 test/unit_legacy/vagrant/action/vm/destroy_unused_network_interfaces_test.rb
vagrantup-1.0.6 test/unit_legacy/vagrant/action/vm/destroy_unused_network_interfaces_test.rb
vagrantup-1.0.5 test/unit_legacy/vagrant/action/vm/destroy_unused_network_interfaces_test.rb
vagrantup-1.0.4 test/unit_legacy/vagrant/action/vm/destroy_unused_network_interfaces_test.rb
vagrantup-1.0.3 test/unit_legacy/vagrant/action/vm/destroy_unused_network_interfaces_test.rb
vagrantup-1.0.2 test/unit_legacy/vagrant/action/vm/destroy_unused_network_interfaces_test.rb
vagrantup-1.0.1 test/unit_legacy/vagrant/action/vm/destroy_unused_network_interfaces_test.rb
vagrantup-1.0.0 test/unit_legacy/vagrant/action/vm/destroy_unused_network_interfaces_test.rb
vagrantup-0.9.99.2 test/unit_legacy/vagrant/action/vm/destroy_unused_network_interfaces_test.rb
vagrantup-0.9.99.1 test/unit_legacy/vagrant/action/vm/destroy_unused_network_interfaces_test.rb
vagrantup-0.9.7 test/unit_legacy/vagrant/action/vm/destroy_unused_network_interfaces_test.rb
vagrantup-0.9.6 test/unit_legacy/vagrant/action/vm/destroy_unused_network_interfaces_test.rb
vagrantup-0.9.5 test/unit_legacy/vagrant/action/vm/destroy_unused_network_interfaces_test.rb
vagrantup-0.9.4 test/unit_legacy/vagrant/action/vm/destroy_unused_network_interfaces_test.rb
vagrantup-0.9.3 test/unit_legacy/vagrant/action/vm/destroy_unused_network_interfaces_test.rb
vagrantup-0.9.2 test/unit_legacy/vagrant/action/vm/destroy_unused_network_interfaces_test.rb