VMs have their own loggers

This commit is contained in:
Mitchell Hashimoto 2010-05-20 15:49:27 -07:00
parent fa9bdad175
commit a1794dca80
2 changed files with 15 additions and 1 deletions

View File

@ -4,6 +4,7 @@ module Vagrant
attr_reader :env
attr_reader :system
attr_reader :logger
attr_reader :name
attr_accessor :vm
@ -42,6 +43,8 @@ module Vagrant
# Load the associated system.
load_system!
end
@logger = ResourceLogger.new(@name, @env)
end
# Loads the system associated with the VM. The system class is

View File

@ -37,7 +37,8 @@ class VMTest < Test::Unit::TestCase
context "vagrant VM instance" do
setup do
@vm = Vagrant::VM.new(:env => @env, :vm => @mock_vm)
@vm_name = "foo"
@vm = Vagrant::VM.new(:env => @env, :vm => @mock_vm, :vm_name => @vm_name)
@mock_vm.stubs(:uuid).returns("foo")
end
@ -53,6 +54,16 @@ class VMTest < Test::Unit::TestCase
end
end
context "the logger" do
should "create a logger for the proper environment" do
logger = @vm.logger
assert logger
assert logger.is_a?(Vagrant::ResourceLogger)
assert_equal @vm.env, logger.env
assert_equal @vm_name, logger.resource
end
end
context "accessing the SSH object" do
setup do
# Reset this to nil to force the reload