From b97c257904e138136ea5be4d18f8ab3a2f2d82da Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 20 Jun 2010 02:24:07 -0700 Subject: [PATCH] `setup_unison` implemented on shared folder action --- lib/vagrant/actions/vm/shared_folders.rb | 9 +++++- .../vagrant/actions/vm/shared_folders_test.rb | 30 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/lib/vagrant/actions/vm/shared_folders.rb b/lib/vagrant/actions/vm/shared_folders.rb index 0de027367..ec8486ca7 100644 --- a/lib/vagrant/actions/vm/shared_folders.rb +++ b/lib/vagrant/actions/vm/shared_folders.rb @@ -54,7 +54,14 @@ module Vagrant def setup_unison return if unison_folders.empty? - # TODO + logger.info "Setting up unison crontab..." + runner.ssh.execute do |ssh| + runner.system.prepare_unison(ssh) + + unison_folders.each do |name, data| + runner.system.create_unison(ssh, data) + end + end end def clear_shared_folders diff --git a/test/vagrant/actions/vm/shared_folders_test.rb b/test/vagrant/actions/vm/shared_folders_test.rb index 112f354da..a1fc50da6 100644 --- a/test/vagrant/actions/vm/shared_folders_test.rb +++ b/test/vagrant/actions/vm/shared_folders_test.rb @@ -164,6 +164,36 @@ class SharedFoldersActionTest < Test::Unit::TestCase end context "setting up unison" do + setup do + @ssh = mock("ssh") + @runner.ssh.stubs(:execute).yields(@ssh) + @folders = stub_shared_folders do |config| + config.vm.share_folder("foo", "bar", "baz", :sync => true) + config.vm.share_folder("bar", "foo", "baz") + end + end + + should "do nothing if unison folders is empty" do + @action.stubs(:unison_folders).returns({}) + @runner.ssh.expects(:execute).never + @action.setup_unison + end + + should "prepare unison then create for each folder" do + seq = sequence("unison seq") + @runner.system.expects(:prepare_unison).with(@ssh).once.in_sequence(seq) + @folders.each do |name, data| + if data[:sync] + @runner.system.expects(:create_unison).with do |ssh, opts| + assert_equal @ssh, ssh + assert_equal data, opts + true + end + end + end + + @action.setup_unison + end end end