Make the file download the default for `vagrant box add`. Tests.
This commit is contained in:
parent
c9cf2867ea
commit
cab1e4e49b
|
@ -26,13 +26,24 @@ module Vagrant
|
||||||
end
|
end
|
||||||
|
|
||||||
def instantiate_downloader
|
def instantiate_downloader
|
||||||
@env["download.classes"].each do |klass|
|
# Assign to a temporary variable since this is easier to type out,
|
||||||
if klass.match?(@env["box"].uri)
|
# since it is used so many times.
|
||||||
|
classes = @env["download.classes"]
|
||||||
|
|
||||||
|
# Find the class to use.
|
||||||
|
classes.each_index do |i|
|
||||||
|
klass = classes[i]
|
||||||
|
|
||||||
|
# Use the class if it matches the given URI or if this
|
||||||
|
# is the last class...
|
||||||
|
if classes.length == (i + 1) || klass.match?(@env["box"].uri)
|
||||||
@env.ui.info I18n.t("vagrant.actions.box.download.with", :class => klass.to_s)
|
@env.ui.info I18n.t("vagrant.actions.box.download.with", :class => klass.to_s)
|
||||||
@downloader = klass.new(@env)
|
@downloader = klass.new(@env)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# This line should never be reached, but we'll keep this here
|
||||||
|
# just in case for now.
|
||||||
raise Errors::BoxDownloadUnknownType if !@downloader
|
raise Errors::BoxDownloadUnknownType if !@downloader
|
||||||
|
|
||||||
@downloader.prepare(@env["box"].uri)
|
@downloader.prepare(@env["box"].uri)
|
||||||
|
|
|
@ -19,4 +19,17 @@ class BoxTest < AcceptanceTest
|
||||||
results = execute("vagrant", "box", "list")
|
results = execute("vagrant", "box", "list")
|
||||||
assert(results.stdout.read =~ /^foo$/, "Box should exist after it is added")
|
assert(results.stdout.read =~ /^foo$/, "Box should exist after it is added")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "give a helpful error message if the file doesn't exist" do
|
||||||
|
# Add a box which doesn't exist
|
||||||
|
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 "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")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue