core: add test for removing box version [GH-3364]
/cc @berendt - Added a test
This commit is contained in:
parent
4c90a5d002
commit
8195f7faab
|
@ -11,6 +11,8 @@ BUG FIXES:
|
|||
|
||||
- core: Vagrant won't collide with newer versions of Bundler [GH-3193]
|
||||
- core: Allow provisioner plugins to not have a config class. [GH-3272]
|
||||
- core: Removing a specific box version that doesn't exist doesn't
|
||||
crash Vagrant. [GH-3364]
|
||||
- commands/status: Machine readable output contains the target. [GH-3218]
|
||||
- guests/debian: Changing host name works properly. [GH-3283]
|
||||
- providers/virtualbox: Add missing translation for stopping status. [GH-3368]
|
||||
|
|
|
@ -60,12 +60,7 @@ module Vagrant
|
|||
provider: box_provider.to_s,
|
||||
versions: all_versions.join(", ")
|
||||
end
|
||||
end
|
||||
|
||||
box = env[:box_collection].find(
|
||||
box_name, box_provider, box_version)
|
||||
|
||||
if box == nil
|
||||
elsif !all_versions.include?(box_version)
|
||||
raise Errors::BoxRemoveVersionNotFound,
|
||||
name: box_name,
|
||||
provider: box_provider.to_s,
|
||||
|
@ -73,6 +68,9 @@ module Vagrant
|
|||
versions: all_versions.join(", ")
|
||||
end
|
||||
|
||||
box = env[:box_collection].find(
|
||||
box_name, box_provider, box_version)
|
||||
|
||||
env[:ui].info(I18n.t("vagrant.commands.box.removing",
|
||||
:name => box.name,
|
||||
:provider => box.provider))
|
||||
|
|
|
@ -434,12 +434,12 @@ en:
|
|||
|
||||
The providers for this are: %{providers}
|
||||
box_remove_version_not_found: |-
|
||||
You requested to remove the box '%{name}' with provider
|
||||
'%{provider}' in version '%{version}'. The box '%{name}'
|
||||
exists but not in the specified version '%{version}'.
|
||||
Please double-check and try again.
|
||||
You requested to remove the box '%{name}' version '%{version}' with
|
||||
provider '%{provider}', but that specific version of the box is
|
||||
not install. Please double-check and try again. The available versions
|
||||
for this box are:
|
||||
|
||||
The available versions for this box are: %{versions}
|
||||
%{versions}
|
||||
box_server_not_set: |-
|
||||
A URL to a Vagrant Cloud server is not set, so boxes cannot
|
||||
be added with a shorthand ("mitchellh/precise64") format.
|
||||
|
|
|
@ -54,6 +54,26 @@ describe Vagrant::Action::Builtin::BoxRemove do
|
|||
expect(env[:box_removed]).to equal(box)
|
||||
end
|
||||
|
||||
it "deletes the box with the specified version if given" do
|
||||
box_collection.stub(
|
||||
all: [
|
||||
["foo", "1.0", :virtualbox],
|
||||
["foo", "1.1", :virtualbox],
|
||||
])
|
||||
|
||||
env[:box_name] = "foo"
|
||||
env[:box_version] = "1.0"
|
||||
|
||||
expect(box_collection).to receive(:find).with(
|
||||
"foo", :virtualbox, "1.0").and_return(box)
|
||||
expect(box).to receive(:destroy!).once
|
||||
expect(app).to receive(:call).with(env).once
|
||||
|
||||
subject.call(env)
|
||||
|
||||
expect(env[:box_removed]).to equal(box)
|
||||
end
|
||||
|
||||
it "errors if the box doesn't exist" do
|
||||
box_collection.stub(all: [])
|
||||
|
||||
|
@ -105,4 +125,16 @@ describe Vagrant::Action::Builtin::BoxRemove do
|
|||
expect { subject.call(env) }.
|
||||
to raise_error(Vagrant::Errors::BoxRemoveMultiVersion)
|
||||
end
|
||||
|
||||
it "errors if the specified version doesn't exist" do
|
||||
env[:box_name] = "foo"
|
||||
env[:box_version] = "1.1"
|
||||
|
||||
box_collection.stub(all: [["foo", "1.0", :virtualbox]])
|
||||
|
||||
expect(app).to receive(:call).never
|
||||
|
||||
expect { subject.call(env) }.
|
||||
to raise_error(Vagrant::Errors::BoxRemoveVersionNotFound)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue