BaseVMNotFoundError -> BaseVMNotFound and test [closes GH-200]

This commit is contained in:
Ches Martin 2010-11-02 18:49:25 +07:00 committed by Mitchell Hashimoto
parent 9e7ed2cfe5
commit 8bff03fb80
2 changed files with 28 additions and 1 deletions

View File

@ -16,7 +16,7 @@ module Vagrant
def package_base def package_base
vm = VM.find(options[:base], env) vm = VM.find(options[:base], env)
raise Errors::BaseVMNotFoundError.new(:name => options[:base]) if !vm.created? raise Errors::BaseVMNotFound.new(:name => options[:base]) if !vm.created?
package_vm(vm) package_vm(vm)
end end

View File

@ -0,0 +1,27 @@
require "test_helper"
class CommandPackageCommandTest < Test::Unit::TestCase
setup do
@klass = Vagrant::Command::PackageCommand
@env = vagrant_env
end
def command(args, opts, env)
@klass.new(args, opts, { :env => env })
end
context "initialization" do
should "require an environment" do
assert_raises(Vagrant::Errors::CLIMissingEnvironment) { command([], {}, nil) }
assert_nothing_raised { command([], {}, @env) }
end
end
should "raise an exception if VM for supplied base option is not found" do
Vagrant::VM.stubs(:find).returns(Vagrant::VM.new(nil))
assert_raises(Vagrant::Errors::BaseVMNotFound) {
command([], { :base => "foo" }, @env).execute
}
end
end