Env.persist_vm also persists UUID to the ActiveList
This commit is contained in:
parent
62d3172e57
commit
05c4c2f838
|
@ -35,8 +35,8 @@ msg
|
|||
end
|
||||
|
||||
def persist
|
||||
logger.info "Persisting the VM UUID (#{@runner.vm.uuid})..."
|
||||
Env.persist_vm(@runner.vm)
|
||||
logger.info "Persisting the VM UUID (#{@runner.uuid})..."
|
||||
Env.persist_vm(@runner)
|
||||
end
|
||||
|
||||
def setup_mac_address
|
||||
|
|
|
@ -107,9 +107,13 @@ msg
|
|||
end
|
||||
|
||||
def persist_vm(vm)
|
||||
# Save to the dotfile for this project
|
||||
File.open(dotfile_path, 'w+') do |f|
|
||||
f.write(vm.uuid)
|
||||
end
|
||||
|
||||
# Also add to the global store
|
||||
ActiveList.add(vm)
|
||||
end
|
||||
|
||||
def load_root_path!(path=nil)
|
||||
|
|
|
@ -78,8 +78,8 @@ class UpActionTest < Test::Unit::TestCase
|
|||
|
||||
context "persisting" do
|
||||
should "persist the VM with Env" do
|
||||
@vm.stubs(:uuid)
|
||||
Vagrant::Env.expects(:persist_vm).with(@vm).once
|
||||
@mock_vm.stubs(:uuid)
|
||||
Vagrant::Env.expects(:persist_vm).with(@mock_vm).once
|
||||
@action.persist
|
||||
end
|
||||
end
|
||||
|
|
|
@ -161,7 +161,7 @@ class EnvTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
context "initial load" do
|
||||
test "load! should load the config and set the persisted_uid" do
|
||||
should "load! should load the config and set the persisted_uid" do
|
||||
call_seq = sequence("call_sequence")
|
||||
Vagrant::Env.expects(:load_root_path!).once.in_sequence(call_seq)
|
||||
Vagrant::Env.expects(:load_config!).once.in_sequence(call_seq)
|
||||
|
@ -177,16 +177,24 @@ class EnvTest < Test::Unit::TestCase
|
|||
context "persisting the VM into a file" do
|
||||
setup do
|
||||
mock_config
|
||||
|
||||
@vm = mock("vm")
|
||||
@vm.stubs(:uuid).returns("foo")
|
||||
|
||||
File.stubs(:open)
|
||||
Vagrant::ActiveList.stubs(:add)
|
||||
end
|
||||
|
||||
test "should save it to the dotfile path" do
|
||||
vm = mock("vm")
|
||||
vm.stubs(:uuid).returns("foo")
|
||||
|
||||
should "should save it to the dotfile path" do
|
||||
filemock = mock("filemock")
|
||||
filemock.expects(:write).with(vm.uuid)
|
||||
filemock.expects(:write).with(@vm.uuid)
|
||||
File.expects(:open).with(Vagrant::Env.dotfile_path, 'w+').once.yields(filemock)
|
||||
Vagrant::Env.persist_vm(vm)
|
||||
Vagrant::Env.persist_vm(@vm)
|
||||
end
|
||||
|
||||
should "add the VM to the activelist" do
|
||||
Vagrant::ActiveList.expects(:add).with(@vm)
|
||||
Vagrant::Env.persist_vm(@vm)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue