Test that adding an invalid box results in an error

This commit is contained in:
Mitchell Hashimoto 2011-11-03 22:22:19 -07:00
parent d0e191a96c
commit d9d8029783
1 changed files with 13 additions and 2 deletions

View File

@ -20,14 +20,25 @@ class BoxTest < AcceptanceTest
assert(results.stdout.read =~ /^foo$/, "Box should exist after it is added")
end
should "give a helpful error message if the file doesn't exist" do
# Add a box which doesn't exist
should "give an error if the file doesn't exist" do
results = execute("vagrant", "box", "add", "foo", "/tmp/nope/nope/nope/nonono.box")
assert(!results.success?, "Box add should fail.")
assert(results.stdout.read =~ /^The specified path to a file doesn't exist.$/,
"This should show an error message about the file not existing.")
end
should "give an error if the file is not a valid box" do
invalid = @environment.workdir.join("nope.txt")
invalid.open("w+") do |f|
f.write("INVALID!")
end
results = execute("vagrant", "box", "add", "foo", invalid.to_s)
assert(!results.success?, "Box add should fail.")
assert(results.stdout.read =~ /^The box file you're attempting to add is invalid./,
"should show an error message")
end
should "add a box from an HTTP server" do
# TODO: Spin up an HTTP server to serve a file, add and test.
skip("Need to setup HTTP server functionality")