test/vagrant/action/vm/nfs_test.rb in vagrant-0.5.4 vs test/vagrant/action/vm/nfs_test.rb in vagrant-0.6.0

- old
+ new

@@ -1,11 +1,11 @@ require "test_helper" class NFSVMActionTest < Test::Unit::TestCase setup do @klass = Vagrant::Action::VM::NFS - @app, @env = mock_action_data + @app, @env = action_env @vm = mock("vm") @vm.stubs(:system).returns(mock("system")) @env.env.stubs(:host).returns(Vagrant::Hosts::Base.new(@env)) @env.env.config.vm.network("192.168.55.1") @@ -63,37 +63,17 @@ @instance.expects(:clear_nfs_exports).never @app.expects(:call).with(@env).in_sequence(seq) @instance.expects(:mount_folders).never @instance.call(@env) end + end - should "halt chain if environment error occured" do - @env.error!(:foo) - - seq = sequence('seq') - @instance.expects(:extract_folders).in_sequence(seq) - @instance.expects(:prepare_folders).in_sequence(seq) - @instance.expects(:clear_nfs_exports).in_sequence(seq) - @instance.expects(:export_folders).in_sequence(seq) - @app.expects(:call).never - @instance.call(@env) + context "recovery" do + should "clear NFS exports" do + @instance.expects(:clear_nfs_exports).with(@env).once + @instance.recover(@env) end - - should "not mount folders if an error occured" do - seq = sequence("seq") - @app.expects(:call).in_sequence(seq).with() do - # Use this mark the env as error - @env.error!(:foo) - - true - end - - @instance.expects(:clear_nfs_exports).with(@env).in_sequence(seq) - - @instance.expects(:mount_folders).never - @instance.call(@env) - end end context "extracting folders" do setup do @env.env.config.vm.shared_folders.clear @@ -127,15 +107,16 @@ @stat = mock("stat") File.stubs(:stat).returns(@stat) end should "return nil if the perm is not set" do + @env.env.config.nfs.map_uid = nil assert_nil @instance.prepare_permission(:uid, {:gid => 7}) end should "return nil if the perm explicitly says nil" do - assert_nil @instance.prepare_permission(:uid, {:uid => nil}) + assert_nil @instance.prepare_permission(:uid, {:map_uid => nil}) end should "return the set value if it is set" do assert_equal 7, @instance.prepare_permission(:gid, {:map_gid => 7}) end @@ -162,17 +143,10 @@ should "call nfs_export on the host" do @env["host"].expects(:nfs_export).with(@instance.guest_ip, @instance.folders) @instance.export_folders end - - should "error the environment if exception is raised" do - @env["host"].expects(:nfs_export).raises(Vagrant::Action::ActionException.new(:foo)) - @instance.export_folders - assert @env.error? - assert_equal :foo, @env.error.first - end end context "mounting folders" do setup do @instance.stubs(:host_ip).returns("foo") @@ -238,32 +212,33 @@ @env.env.host.stubs(:nfs?).returns(true) end should "error environment if host is nil" do @env.env.stubs(:host).returns(nil) - @instance.verify_settings - assert @env.error? - assert_equal :nfs_host_required, @env.error.first + assert_raises(Vagrant::Errors::NFSHostRequired) { + @instance.verify_settings + } end should "error environment if host does not support NFS" do @env.env.host.stubs(:nfs?).returns(false) - @instance.verify_settings - assert @env.error? - assert_equal :nfs_not_supported, @env.error.first + assert_raises(Vagrant::Errors::NFSNotSupported) { + @instance.verify_settings + } end should "error environment if host only networking is not enabled" do @env.env.config.vm.network_options.clear - @instance.verify_settings - assert @env.error? - assert_equal :nfs_no_host_network, @env.error.first + assert_raises(Vagrant::Errors::NFSNoHostNetwork) { + @instance.verify_settings + } end should "be fine if everything passes" do @env.env.host.stubs(:nfs?).returns(true) - @instance.verify_settings - assert !@env.error? + assert_nothing_raised { + @instance.verify_settings + } end end end end