test/vagrant/systems/linux_test.rb in vagrantup-0.4.1 vs test/vagrant/systems/linux_test.rb in vagrantup-0.4.3.dev
- old
+ new
@@ -41,66 +41,71 @@
@instance.mount_shared_folder(@ssh, @name, @guestpath)
end
end
- context "preparing sync" do
+ context "preparing unison" do
setup do
@ssh.stubs(:exec!)
+ @ssh.stubs(:upload!)
@vm.stubs(:ssh).returns(@ssh)
- @vm.ssh.stubs(:upload!)
end
- should "upload the sync template" do
- @vm.ssh.expects(:upload!).with do |string_io, guest_path|
- string_io.string =~ /#!\/bin\/sh/ && guest_path == @mock_env.config.vm.sync_script
+ should "upload the script" do
+ @vm.ssh.expects(:upload!).with do |script, path|
+ assert_equal @mock_env.config.unison.script, path
+ true
end
- @instance.prepare_sync(@ssh)
+ @instance.prepare_unison(@ssh)
end
- should "remove old crontab entries file" do
- @ssh.expects(:exec!).with("sudo rm #{@mock_env.config.vm.sync_crontab_entry_file}", :error_check => false)
- @instance.prepare_sync(@ssh)
+ should "make the script executable" do
+ @ssh.expects(:exec!).with("sudo chmod +x #{@mock_env.config.unison.script}").once
+ @instance.prepare_unison(@ssh)
end
- should "prepare the sync template for execution" do
- @ssh.expects(:exec!).with("sudo chmod +x #{@mock_env.config.vm.sync_script}")
- @instance.prepare_sync(@ssh)
+ should "remove old crontab entry file" do
+ @ssh.expects(:exec!).with("sudo rm #{@mock_env.config.unison.crontab_entry_file}", :error_check => false).once
+ @instance.prepare_unison(@ssh)
end
end
- context "setting up an sync folder" do
+ context "creating unison entry" do
setup do
@ssh.stubs(:exec!)
+ @options = {
+ :guestpath => "foo",
+ :original => { :guestpath => "bar!" }
+ }
end
- should "create the new rysnc destination directory" do
- sync_path = 'foo'
- @ssh.expects(:exec!).with("sudo mkdir -p #{sync_path}")
- @instance.create_sync(@ssh, :syncpath => "foo")
+ should "render the crontab entry with proper variables" do
+ variables = {
+ :from => @options[:guestpath],
+ :to => @options[:original][:guestpath],
+ :options => @mock_env.config.unison.options,
+ :script => @mock_env.config.unison.script,
+ :log_file => @mock_env.config.unison.log_file % "bar-"
+ }
+ Vagrant::Util::TemplateRenderer.expects(:render).with('/unison/crontab_entry',
+ variables).once
+ @instance.create_unison(@ssh, @options)
end
- should "add an entry to the crontab file" do
- @instance.expects(:render_crontab_entry).returns('foo')
- @ssh.expects(:exec!).with do |cmd|
- cmd =~ /echo/ && cmd =~ /foo/ && cmd =~ /#{@mock_env.config.vm.sync_crontab_entry_file}/
- end
- @instance.create_sync(@ssh, {})
+ should "remove the .unison directory" do
+ @ssh.expects(:exec!).with("sudo rm -rf ~/.unison")
+ @instance.create_unison(@ssh, @options)
end
- should "use the crontab entry file to define vagrant users cron entries" do
- @ssh.expects(:exec!).with("crontab #{@mock_env.config.vm.sync_crontab_entry_file}")
- @instance.create_sync(@ssh, {})
+ should "remove the original guestpath" do
+ @ssh.expects(:exec!).with("sudo rm -rf #{@options[:original][:guestpath]}")
+ @instance.create_unison(@ssh, @options)
end
- should "chown the sync directory" do
- @instance.expects(:chown).with(@ssh, "foo")
- @instance.create_sync(@ssh, :syncpath => "foo")
- end
-
- should "return provide a formatted crontab entry that runs every minute" do
- assert @instance.render_crontab_entry({}).include?("* * * * *")
+ should "enable the crontab file" do
+ @ssh.expects(:exec!).with("crontab #{@mock_env.config.unison.crontab_entry_file}")
+ @instance.create_unison(@ssh, @options)
end
end
#-------------------------------------------------------------------
# "Private" methods tests