From 5a13347fb4f68a94010cd78fa9ede72a6a31ba50 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 7 Sep 2010 01:01:58 -0700 Subject: [PATCH] Fix issue with local data store not being properly cleared for VM destruction --- lib/vagrant/vm.rb | 4 ++-- test/vagrant/data_store_test.rb | 7 +++++++ test/vagrant/vm_test.rb | 6 +++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/vagrant/vm.rb b/lib/vagrant/vm.rb index 1ce8a07ca..26414e481 100644 --- a/lib/vagrant/vm.rb +++ b/lib/vagrant/vm.rb @@ -89,9 +89,9 @@ module Vagrant env.local_data[:active] ||= {} if value && value.uuid - env.local_data[:active][name.to_sym] = value.uuid + env.local_data[:active][name.to_s] = value.uuid else - env.local_data[:active].delete(name.to_sym) + env.local_data[:active].delete(name.to_s) end # Commit the local data so that the next time vagrant is initialized, diff --git a/test/vagrant/data_store_test.rb b/test/vagrant/data_store_test.rb index 221e4c914..61f117495 100644 --- a/test/vagrant/data_store_test.rb +++ b/test/vagrant/data_store_test.rb @@ -26,6 +26,13 @@ class DataStoreTest < Test::Unit::TestCase assert_equal @initial_data["foo"], @instance[:foo] end + should "read the data by stringifying keys" do + @instance[:bar] = { "baz" => "yay" } + @instance.commit + @instance = @klass.new(@db_file) + assert_equal "yay", @instance[:bar]["baz"] + end + should "write the data, but not save it right away" do @instance[:foo] = "changed" assert_equal "changed", @instance[:foo] diff --git a/test/vagrant/vm_test.rb b/test/vagrant/vm_test.rb index d88c89929..5b2070698 100644 --- a/test/vagrant/vm_test.rb +++ b/test/vagrant/vm_test.rb @@ -57,13 +57,13 @@ class VMTest < Test::Unit::TestCase should "add the VM to the active list" do assert @env.local_data.empty? @vm.vm = @raw_vm - assert_equal @raw_vm.uuid, @env.local_data[:active][@vm.name.to_sym] + assert_equal @raw_vm.uuid, @env.local_data[:active][@vm.name.to_s] end should "remove the VM from the active list if nil is given" do - @env.local_data[:active] = { @vm.name.to_sym => "foo" } + @env.local_data[:active] = { @vm.name.to_s => "foo" } - assert @env.local_data[:active].has_key?(@vm.name.to_sym) # sanity + assert @env.local_data[:active].has_key?(@vm.name.to_s) # sanity @vm.vm = nil # This becomes empty because vm= will commit the local data which