More SF tests passing...

This commit is contained in:
Mitchell Hashimoto 2010-06-19 11:44:13 -07:00
parent b0879dea6a
commit 4c1ac8d2c1
1 changed files with 31 additions and 24 deletions

View File

@ -7,9 +7,20 @@ class SharedFoldersActionTest < Test::Unit::TestCase
end end
def stub_shared_folders def stub_shared_folders
folders = [%w{foo from to}, %w{bar bfrom bto}] env = mock_environment do |config|
@action.expects(:shared_folders).returns(folders) config.vm.shared_folders.clear
folders
if block_given?
yield config
else
folders = [%w{foo fooguest foohost}, %w{bar barguest barhost}]
folders.each do |data|
config.vm.share_folder(*data)
end
end
end
@runner.stubs(:env).returns(env)
end end
context "before boot" do context "before boot" do
@ -32,7 +43,7 @@ class SharedFoldersActionTest < Test::Unit::TestCase
"bar" => %W[foo baz] "bar" => %W[foo baz]
} }
mock_env do |config| stub_shared_folders do |config|
data.each do |name, value| data.each do |name, value|
config.vm.share_folder(name, *value) config.vm.share_folder(name, *value)
end end
@ -52,7 +63,7 @@ class SharedFoldersActionTest < Test::Unit::TestCase
guest = "bar" guest = "bar"
host = "baz" host = "baz"
mock_env do |config| stub_shared_folders do |config|
config.vm.share_folder(name, guest, host, :sync => true) config.vm.share_folder(name, guest, host, :sync => true)
end end
@ -60,15 +71,6 @@ class SharedFoldersActionTest < Test::Unit::TestCase
assert_equal "#{guest}#{@runner.env.config.unison.folder_suffix}", result[name][:guestpath] assert_equal "#{guest}#{@runner.env.config.unison.folder_suffix}", result[name][:guestpath]
assert_equal guest, result[name][:original][:guestpath] assert_equal guest, result[name][:original][:guestpath]
end end
def mock_env
env = mock_environment do |config|
config.vm.shared_folders.clear
yield config
end
@runner.expects(:env).returns(env)
end
end end
context "clearing shared folders" do context "clearing shared folders" do
@ -97,19 +99,24 @@ class SharedFoldersActionTest < Test::Unit::TestCase
context "setting up shared folder metadata" do context "setting up shared folder metadata" do
setup do setup do
@folders = stub_shared_folders stub_shared_folders
end end
# should "add all shared folders to the VM" do should "add all shared folders to the VM" do
# share_seq = sequence("share_seq") shared_folders = []
# shared_folders = mock("shared_folders") data = %W[foo bar]
# shared_folders.expects(:<<).in_sequence(share_seq).with() { |sf| sf.name == "foo" && sf.host_path == "from" } shared_folders.expects(:<<).times(data.length).with() do |sf|
# shared_folders.expects(:<<).in_sequence(share_seq).with() { |sf| sf.name == "bar" && sf.host_path == "bfrom" } hostpath = File.expand_path("#{sf.name}host", @runner.env.root_path)
# @vm.stubs(:shared_folders).returns(shared_folders) assert data.include?(sf.name)
# @vm.expects(:save).once assert_equal hostpath, sf.host_path
true
end
# @action.create_metadata @vm.stubs(:shared_folders).returns(shared_folders)
# end @vm.expects(:save).once
@action.create_metadata
end
end end
# context "mounting the shared folders" do # context "mounting the shared folders" do