core: Store the actual box data, not just the name

This commit is contained in:
Mitchell Hashimoto 2014-04-22 16:46:11 -07:00
parent 519c8af971
commit 2660252ede
2 changed files with 21 additions and 3 deletions

View File

@ -254,13 +254,21 @@ module Vagrant
if index_uuid.nil?
# Create the index entry and save it
entry = MachineIndex::Entry.new
entry.extra_data["box"] = @config.vm.box
entry.local_data_path = @env.local_data_path
entry.name = @name.to_s
entry.provider = @provider_name.to_s
entry.state = "preparing"
entry.vagrantfile_path = @env.root_path
entry.vagrantfile_name = @env.vagrantfile_name
if @box
entry.extra_data["box"] = {
"name" => @box.name,
"provider" => @box.provider.to_s,
"version" => @box.version.to_s,
}
end
entry = @env.machine_index.set(entry)
@env.machine_index.release(entry)

View File

@ -403,7 +403,13 @@ describe Vagrant::Machine do
end
it "is set one when setting an ID" do
subject.config.vm.box = "FOO"
# Setup the box information
box = double("box")
box.stub(name: "foo")
box.stub(provider: :bar)
box.stub(version: "1.2.3")
subject.box = box
subject.id = "foo"
uuid = subject.index_uuid
@ -412,12 +418,16 @@ describe Vagrant::Machine do
# Test the entry itself
entry = env.machine_index.get(uuid)
expect(entry.extra_data["box"]).to eq(subject.config.vm.box)
expect(entry.name).to eq(subject.name)
expect(entry.provider).to eq(subject.provider_name.to_s)
expect(entry.state).to eq("preparing")
expect(entry.vagrantfile_path).to eq(env.root_path)
expect(entry.vagrantfile_name).to eq(env.vagrantfile_name)
expect(entry.extra_data["box"]).to eq({
"name" => box.name,
"provider" => box.provider.to_s,
"version" => box.version,
})
env.machine_index.release(entry)
end