core: MachineIndex stores the box associated with a machine when ID is set
This commit is contained in:
parent
8747d938aa
commit
519c8af971
|
@ -254,6 +254,7 @@ module Vagrant
|
||||||
if index_uuid.nil?
|
if index_uuid.nil?
|
||||||
# Create the index entry and save it
|
# Create the index entry and save it
|
||||||
entry = MachineIndex::Entry.new
|
entry = MachineIndex::Entry.new
|
||||||
|
entry.extra_data["box"] = @config.vm.box
|
||||||
entry.local_data_path = @env.local_data_path
|
entry.local_data_path = @env.local_data_path
|
||||||
entry.name = @name.to_s
|
entry.name = @name.to_s
|
||||||
entry.provider = @provider_name.to_s
|
entry.provider = @provider_name.to_s
|
||||||
|
|
|
@ -378,6 +378,8 @@ module Vagrant
|
||||||
# The parameter given should be nil if this is being created
|
# The parameter given should be nil if this is being created
|
||||||
# publicly.
|
# publicly.
|
||||||
def initialize(id=nil, raw=nil)
|
def initialize(id=nil, raw=nil)
|
||||||
|
@extra_data = {}
|
||||||
|
|
||||||
# Do nothing if we aren't given a raw value. Otherwise, parse it.
|
# Do nothing if we aren't given a raw value. Otherwise, parse it.
|
||||||
return if !raw
|
return if !raw
|
||||||
|
|
||||||
|
|
|
@ -403,11 +403,22 @@ describe Vagrant::Machine do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is set one when setting an ID" do
|
it "is set one when setting an ID" do
|
||||||
|
subject.config.vm.box = "FOO"
|
||||||
subject.id = "foo"
|
subject.id = "foo"
|
||||||
|
|
||||||
uuid = subject.index_uuid
|
uuid = subject.index_uuid
|
||||||
expect(uuid).to_not be_nil
|
expect(uuid).to_not be_nil
|
||||||
expect(new_instance.index_uuid).to eq(uuid)
|
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
|
end
|
||||||
|
|
||||||
it "deletes the UUID when setting to nil" do
|
it "deletes the UUID when setting to nil" do
|
||||||
|
|
Loading…
Reference in New Issue