Helper method to create a new VM on an environment. Interim method.
This commit is contained in:
parent
2fef27ec8b
commit
2661845b5d
|
@ -167,9 +167,13 @@ module Vagrant
|
||||||
end
|
end
|
||||||
|
|
||||||
#---------------------------------------------------------------
|
#---------------------------------------------------------------
|
||||||
# Methods to persist/unpersist VM
|
# Methods to manage VM
|
||||||
#---------------------------------------------------------------
|
#---------------------------------------------------------------
|
||||||
|
|
||||||
|
def create_vm
|
||||||
|
@vm = VM.new
|
||||||
|
end
|
||||||
|
|
||||||
def persist_vm
|
def persist_vm
|
||||||
# Save to the dotfile for this project
|
# Save to the dotfile for this project
|
||||||
File.open(dotfile_path, 'w+') do |f|
|
File.open(dotfile_path, 'w+') do |f|
|
||||||
|
|
|
@ -429,20 +429,33 @@ class EnvironmentTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "persisting/depersisting VM" do
|
context "managing VM" do
|
||||||
setup do
|
setup do
|
||||||
@env = mock_environment
|
@env = mock_environment
|
||||||
|
|
||||||
@dotfile_path = "foo"
|
@dotfile_path = "foo"
|
||||||
@env.stubs(:dotfile_path).returns(@dotfile_path)
|
@env.stubs(:dotfile_path).returns(@dotfile_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
def mock_vm
|
||||||
@vm = mock("vm")
|
@vm = mock("vm")
|
||||||
@vm.stubs(:uuid).returns("foo")
|
@vm.stubs(:uuid).returns("foo")
|
||||||
@env.stubs(:vm).returns(@vm)
|
@env.stubs(:vm).returns(@vm)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "creating a new VM" do
|
||||||
|
should "create a new VM" do
|
||||||
|
assert_nil @env.vm
|
||||||
|
@env.create_vm
|
||||||
|
assert !@env.vm.nil?
|
||||||
|
assert @env.vm.is_a?(Vagrant::VM)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "persisting the VM into a file" do
|
context "persisting the VM into a file" do
|
||||||
setup do
|
setup do
|
||||||
|
mock_vm
|
||||||
|
|
||||||
File.stubs(:open)
|
File.stubs(:open)
|
||||||
Vagrant::ActiveList.stubs(:add)
|
Vagrant::ActiveList.stubs(:add)
|
||||||
end
|
end
|
||||||
|
@ -462,6 +475,8 @@ class EnvironmentTest < Test::Unit::TestCase
|
||||||
|
|
||||||
context "depersisting the VM" do
|
context "depersisting the VM" do
|
||||||
setup do
|
setup do
|
||||||
|
mock_vm
|
||||||
|
|
||||||
File.stubs(:exist?).returns(false)
|
File.stubs(:exist?).returns(false)
|
||||||
File.stubs(:delete)
|
File.stubs(:delete)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue