core: MachineIndex stores the box associated with a machine when ID is set

This commit is contained in:
Mitchell Hashimoto 2014-04-22 15:26:56 -07:00
parent 8747d938aa
commit 519c8af971
3 changed files with 14 additions and 0 deletions

View File

@ -254,6 +254,7 @@ 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

View File

@ -378,6 +378,8 @@ module Vagrant
# The parameter given should be nil if this is being created
# publicly.
def initialize(id=nil, raw=nil)
@extra_data = {}
# Do nothing if we aren't given a raw value. Otherwise, parse it.
return if !raw

View File

@ -403,11 +403,22 @@ describe Vagrant::Machine do
end
it "is set one when setting an ID" do
subject.config.vm.box = "FOO"
subject.id = "foo"
uuid = subject.index_uuid
expect(uuid).to_not be_nil
expect(new_instance.index_uuid).to eq(uuid)
# 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)
env.machine_index.release(entry)
end
it "deletes the UUID when setting to nil" do