core: adding from metadata wlil force if specified
This commit is contained in:
parent
2a08302145
commit
c1989603be
|
@ -124,7 +124,8 @@ module Vagrant
|
|||
|
||||
# Add the box!
|
||||
box = env[:box_collection].add(
|
||||
box_url, metadata.name, metadata_version.version)
|
||||
box_url, metadata.name, metadata_version.version,
|
||||
force: env[:box_force])
|
||||
ensure
|
||||
# Make sure we delete the temporary file after we add it,
|
||||
# unless we were interrupted, in which case we keep it around
|
||||
|
|
|
@ -368,5 +368,45 @@ describe Vagrant::Action::Builtin::BoxAdd do
|
|||
expect { subject.call(env) }.
|
||||
to raise_error(Vagrant::Errors::BoxAddNoMatchingProvider)
|
||||
end
|
||||
|
||||
it "force adds a box if specified" do
|
||||
box_path = iso_env.box2_file(:virtualbox)
|
||||
tf = Tempfile.new("vagrant").tap do |f|
|
||||
f.write(<<-RAW)
|
||||
{
|
||||
"name": "foo/bar",
|
||||
"versions": [
|
||||
{
|
||||
"version": "0.5"
|
||||
},
|
||||
{
|
||||
"version": "0.7",
|
||||
"providers": [
|
||||
{
|
||||
"name": "virtualbox",
|
||||
"url": "#{box_path}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
RAW
|
||||
f.close
|
||||
end
|
||||
|
||||
env[:box_force] = true
|
||||
env[:box_url] = tf.path
|
||||
box_collection.should_receive(:add).with do |path, name, version, **opts|
|
||||
expect(checksum(path)).to eq(checksum(box_path))
|
||||
expect(name).to eq("foo/bar")
|
||||
expect(version).to eq("0.7")
|
||||
expect(opts[:force]).to be_true
|
||||
true
|
||||
end.and_return(box)
|
||||
|
||||
app.should_receive(:call).with(env)
|
||||
|
||||
subject.call(env)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue