Skip to content

Commit

Permalink
Nicer error message when box is not found. [closes hashicorpGH-195]
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Oct 22, 2010
1 parent af9fdef commit ef50361
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,5 +1,6 @@
## 0.6.7 (unreleased)

- Proper error message when box is not found for `config.vm.box`. [GH-195]
- Fix output of `vagrant status` with multi-vm to be correct. [GH-196]

## 0.6.6 (October 14, 2010)
Expand Down
4 changes: 3 additions & 1 deletion lib/vagrant/environment.rb
Expand Up @@ -121,7 +121,9 @@ def boxes
#
# @return [Box]
def box
boxes.find(config.vm.box)
result = boxes.find(config.vm.box)
raise Errors::BoxNotFound, :name => config.vm.box if vm && !result
result
end

# Returns the VMs associated with this environment.
Expand Down
5 changes: 5 additions & 0 deletions lib/vagrant/test_helpers.rb
Expand Up @@ -25,11 +25,16 @@ def vagrant_app(*path)
def vagrantfile(*args)
path = args.shift.join("Vagrantfile") if Pathname === args.first
path ||= vagrant_app("Vagrantfile")

# Create this box so that it exists
vagrant_box("base")

str = args.shift || ""
File.open(path.to_s, "w") do |f|
f.puts "Vagrant::Config.run do |config|"
f.puts "config.vagrant.home = '#{home_path}'"
f.puts "config.vm.base_mac = 'foo' if !config.vm.base_mac"
f.puts "config.vm.box = 'base'"
f.puts str
f.puts "end"
end
Expand Down
9 changes: 5 additions & 4 deletions test/vagrant/box_collection_test.rb
Expand Up @@ -13,18 +13,19 @@ class BoxCollectionTest < Test::Unit::TestCase

result = @klass.new(vagrant_env)
names = result.collect { |b| b.name }.sort
assert_equal 2, result.length
assert_equal ["bar", "foo"], names
assert result.length >= 2
assert names.include?("foo")
assert names.include?("bar")
end

should "reload the box list" do
instance = @klass.new(vagrant_env)
assert instance.empty?
amount = instance.length

vagrant_box("foo")

instance.reload!
assert !instance.empty?
assert_equal (amount + 1), instance.length
end

should "find a specific box" do
Expand Down

0 comments on commit ef50361

Please sign in to comment.