Skip to content

Commit

Permalink
core: Store the actual box data, not just the name
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Apr 22, 2014
1 parent 519c8af commit 2660252
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
10 changes: 9 additions & 1 deletion lib/vagrant/machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,21 @@ def id=(value)
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)

Expand Down
14 changes: 12 additions & 2 deletions test/unit/vagrant/machine_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,13 @@ def detect?(machine)
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
Expand All @@ -412,12 +418,16 @@ def detect?(machine)

# 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

Expand Down

0 comments on commit 2660252

Please sign in to comment.