From 32816419f51ce93e4cb206cad1cb1f4539bbddde Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 31 Jan 2010 18:12:09 -0800 Subject: [PATCH] hobo-down now properly uses the new Hobo::VM object rather than a pure VBox VM object. --- lib/hobo/vm.rb | 9 ++++++--- test/hobo/vm_test.rb | 9 ++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/hobo/vm.rb b/lib/hobo/vm.rb index fc8378cec..4e7e1752c 100644 --- a/lib/hobo/vm.rb +++ b/lib/hobo/vm.rb @@ -12,9 +12,7 @@ module Hobo # Tear down a virtual machine. def down Env.require_persisted_vm - - HOBO_LOGGER.info "Destroying VM and associated drives..." - Env.persisted_vm.destroy(:destroy_image => true) + Env.persisted_vm.destroy end # Finds a virtual machine by a given UUID and either returns @@ -38,6 +36,11 @@ module Hobo setup_shared_folder end + def destroy + HOBO_LOGGER.info "Destroying VM and associated drives..." + @vm.destroy(:destroy_image => true) + end + def import HOBO_LOGGER.info "Importing base VM (#{Hobo.config[:vm][:base]})..." @vm = VirtualBox::VM.import(File.expand_path(Hobo.config[:vm][:base])) diff --git a/test/hobo/vm_test.rb b/test/hobo/vm_test.rb index 792639ed9..ef15f2c72 100644 --- a/test/hobo/vm_test.rb +++ b/test/hobo/vm_test.rb @@ -19,7 +19,7 @@ class VMTest < Test::Unit::TestCase end should "destroy the persisted VM and the VM image" do - @persisted_vm.expects(:destroy).with(:destroy_image => true).once + @persisted_vm.expects(:destroy).once Hobo::VM.down end end @@ -64,6 +64,13 @@ class VMTest < Test::Unit::TestCase end end + context "destroying" do + should "destoy the VM along with images" do + @mock_vm.expects(:destroy).with(:destroy_image => true).once + @vm.destroy + end + end + context "importing" do should "call import on VirtualBox::VM with the proper base" do VirtualBox::VM.expects(:import).once