Give proper error message if bad URL given for HTTP box adding
This commit is contained in:
parent
14e7ff8d00
commit
dcd9c2a788
|
@ -48,6 +48,8 @@ module Vagrant
|
|||
end
|
||||
|
||||
env.logger.clear_progress
|
||||
rescue SocketError
|
||||
env.error!(:box_download_http_socket_error, :box_url => source_url)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -70,6 +70,12 @@
|
|||
A box with the name '<%= box_name %>' already exists, please use another name or use `vagrant box remove <%= box_name %>`
|
||||
:box_download_unknown_type: |-
|
||||
Unknown URI type for box download.
|
||||
:box_download_http_socket_error: |-
|
||||
An error occurred while trying to download the specified box. This most
|
||||
often happens if there is no internet connection or the address is
|
||||
invalid.
|
||||
|
||||
Box URL: <%= box_url %>
|
||||
:box_file_exists: |-
|
||||
The specified output file for packaging already exists. Please move
|
||||
the file or modify the output filename parameter then try to package
|
||||
|
|
|
@ -121,7 +121,8 @@ class Test::Unit::TestCase
|
|||
tempfile = mock("tempfile")
|
||||
tempfile.stubs(:write)
|
||||
|
||||
[downloader_klass.new(mock_environment), tempfile]
|
||||
_, env = mock_action_data
|
||||
[downloader_klass.new(env), tempfile]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -42,6 +42,14 @@ class HttpDownloaderTest < Test::Unit::TestCase
|
|||
|
||||
@downloader.download!(@uri, @tempfile)
|
||||
end
|
||||
|
||||
should "error environment if invalid URL given" do
|
||||
Net::HTTP.expects(:new).raises(SocketError.new)
|
||||
@downloader.download!(@uri, @tempfile)
|
||||
|
||||
assert @downloader.env.error?
|
||||
assert_equal :box_download_http_socket_error, @downloader.env.error.first
|
||||
end
|
||||
end
|
||||
|
||||
context "matching the uri" do
|
||||
|
|
Loading…
Reference in New Issue