Sha256: 437e8bb9276acbf2208fa28d9f25b2e2a7b8b5262650a81becca8be2c2954c87

Contents?: true

Size: 1.21 KB

Versions: 11

Compression:

Stored size: 1.21 KB

Contents

require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')

class ImportActionTest < Test::Unit::TestCase
  setup do
    @runner, @vm, @import = mock_action(Vagrant::Actions::VM::Import)

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

    VirtualBox::VM.stubs(:import)
  end

  should "run in a busy block" do
    Vagrant::Busy.expects(:busy).once
    @import.execute!
  end

  should "invoke an around callback around the import" do
    @runner.expects(:invoke_around_callback).with(:import).once
    @import.execute!
  end

  should "call import on VirtualBox::VM with the proper base" do
    VirtualBox::VM.expects(:import).once.with(@ovf_file).returns("foo")
    assert_nothing_raised { @import.execute! }
  end

  should "raise an exception if import is nil" do
    @runner.expects(:vm).returns(nil)
    assert_raises(Vagrant::Actions::ActionException) {
      @import.execute!
    }
  end

  should "set the resulting VM as the VM of the Vagrant VM object" do
    new_vm = mock("new_vm")
    @runner.expects(:vm=).with(new_vm).once
    VirtualBox::VM.expects(:import).returns(new_vm).returns("foo")
    @import.execute!
  end
end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
vagrantup-0.3.4 test/vagrant/actions/vm/import_test.rb
vagrantup-0.3.3 test/vagrant/actions/vm/import_test.rb
vagrantup-0.3.2 test/vagrant/actions/vm/import_test.rb
vagrantup-0.3.1 test/vagrant/actions/vm/import_test.rb
vagrantup-0.3.0 test/vagrant/actions/vm/import_test.rb
vagrant-0.3.4 test/vagrant/actions/vm/import_test.rb
vagrant-0.3.3 test/vagrant/actions/vm/import_test.rb
vagrant-0.3.2 test/vagrant/actions/vm/import_test.rb
vagrant-0.3.1 test/vagrant/actions/vm/import_test.rb
vagrant-0.3.0 test/vagrant/actions/vm/import_test.rb
bmabey-vagrant-0.2.0 test/vagrant/actions/vm/import_test.rb