Sha256: 4ebdca0fca2e1e885e6069a17e8a4dcbae784dd672c707bbf0864f0bffdfec85

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

require "test_helper"

class ImportVMActionTest < Test::Unit::TestCase
  setup do
    @klass = Vagrant::Action::VM::Import
    @app, @env = mock_action_data
    @instance = @klass.new(@app, @env)

    ovf_file = "foo"
    @box = mock("box")
    @box.stubs(:ovf_file).returns(ovf_file)
    @env.env.stubs(:box).returns(@box)

    @env.env.vm = Vagrant::VM.new

    VirtualBox::VM.stubs(:import)
  end

  should "call import on VirtualBox with proper base" do
    VirtualBox::VM.expects(:import).once.with(@env.env.box.ovf_file).returns("foo")
    @instance.call(@env)
  end

  should "call next in chain on success and set VM" do
    vm = mock("vm")
    VirtualBox::VM.stubs(:import).returns(vm)
    @app.expects(:call).with(@env).once
    @instance.call(@env)

    assert_equal vm, @env["vm"].vm
  end

  should "mark environment erroneous and not continue chain on failure" do
    @app.expects(:call).never
    @instance.call(@env)

    assert @env.error?
  end

  should "run the destroy action if interrupted" do
    VirtualBox::VM.stubs(:import).returns(mock("vm"))
    @app.expects(:call).once.with() do |env|
      assert_equal @env, env
      @env.error!(:interrupt)
    end
    @env.env.actions.expects(:run).with(:destroy).once

    @instance.call(@env)
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
vagrantup-0.5.4 test/vagrant/action/vm/import_test.rb
vagrantup-0.5.3 test/vagrant/action/vm/import_test.rb
vagrant-0.5.4 test/vagrant/action/vm/import_test.rb
vagrant-0.5.3 test/vagrant/action/vm/import_test.rb