diff --git a/test/vagrant/provisioners/chef_solo_test.rb b/test/vagrant/provisioners/chef_solo_test.rb index aeaab52e9..50fcce257 100644 --- a/test/vagrant/provisioners/chef_solo_test.rb +++ b/test/vagrant/provisioners/chef_solo_test.rb @@ -42,6 +42,11 @@ class ChefSoloProvisionerTest < Test::Unit::TestCase @action.expects(:share_role_folders).once @action.prepare end + + should "share data bag folders" do + @action.expects(:share_data_bags_folders).once + @action.prepare + end end context "provisioning" do @@ -86,6 +91,22 @@ class ChefSoloProvisionerTest < Test::Unit::TestCase @action.share_role_folders end end + + context "sharing data bag folders" do + setup do + @host_data_bag_paths = ["foo", "bar"] + @action.stubs(:host_data_bag_paths).returns(@host_data_bag_paths) + end + + should "share each data bag folder" do + share_seq = sequence("share_seq") + @host_data_bag_paths.each_with_index do |data_bag, i| + @env.config.vm.expects(:share_folder).with("v-csdb-#{i}", @action.data_bag_path(i), data_bag).in_sequence(share_seq) + end + + @action.share_data_bags_folders + end + end context "host folder paths" do should "ignore VM paths" do @@ -124,6 +145,15 @@ class ChefSoloProvisionerTest < Test::Unit::TestCase assert_equal result, @action.host_role_paths end end + + context "host data bags paths" do + should "get folders path for configured data bag path" do + result = mock("result") + @config.stubs(:data_bags_path).returns("foo") + @action.expects(:host_folder_paths).with(@config.data_bags_path).returns(result) + assert_equal result, @action.host_data_bag_paths + end + end context "folder path" do should "return a proper path to a single folder" do @@ -179,6 +209,19 @@ class ChefSoloProvisionerTest < Test::Unit::TestCase end end + context "data bags path" do + should "return a proper path to a single data bag" do + expected = File.join(@config.provisioning_path, "data_bags-5") + assert_equal expected, @action.data_bag_path(5) + end + + should "properly call folders path and return result" do + result = [:a, :b, :c] + @action.expects(:folders_path).with(@config.data_bags_path, "data_bags").once.returns(result) + assert_equal result.to_json, @action.data_bags_path + end + end + context "generating and uploading chef solo configuration file" do setup do @vm.ssh.stubs(:upload!) @@ -192,7 +235,8 @@ class ChefSoloProvisionerTest < Test::Unit::TestCase :provisioning_path => @config.provisioning_path, :cookbooks_path => @action.cookbooks_path, :recipe_url => @config.recipe_url, - :roles_path => @action.roles_path + :roles_path => @action.roles_path, + :data_bags_path => @action.data_bags_path }) @action.setup_solo_config