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

- old
+ new

@@ -1,11 +1,11 @@ require "test_helper" class ExportVMActionTest < Test::Unit::TestCase setup do @klass = Vagrant::Action::VM::Export - @app, @env = mock_action_data + @app, @env = action_env @vm = mock("vm") @env["vm"] = @vm @internal_vm = mock("internal") @@ -22,51 +22,26 @@ should "call the proper methods then continue chain" do seq = sequence("seq") @instance.expects(:setup_temp_dir).in_sequence(seq) @instance.expects(:export).in_sequence(seq) @app.expects(:call).with(@env).in_sequence(seq) - @instance.expects(:cleanup).in_sequence(seq) + @instance.expects(:recover).in_sequence(seq).with(@env) @instance.call(@env) end should "halt the chain if not powered off" do @internal_vm.stubs(:powered_off?).returns(false) @instance.expects(:setup_temp_dir).never @instance.expects(:export).never @app.expects(:call).with(@env).never - @instance.expects(:cleanup).never + @instance.expects(:recover).never - @instance.call(@env) - assert @env.error? - assert_equal :vm_power_off_to_package, @env.error.first + assert_raises(Vagrant::Errors::VMPowerOffToPackage) { + @instance.call(@env) + } end - - should "halt the chain if env error" do - @internal_vm.stubs(:powered_off?).returns(true) - @instance.expects(:setup_temp_dir).never - @instance.expects(:export).never - @app.expects(:call).with(@env).never - @instance.expects(:cleanup).never - - @env.error!(:interrupt) - @instance.call(@env) - end - - should "halt the chain if env error when call is reached" do - @internal_vm.stubs(:powered_off?).returns(true) - @instance.expects(:setup_temp_dir).once - @instance.expects(:export).once.with() do - @env.error!(:interrupt) - true - end - - @app.expects(:call).with(@env).never - @instance.expects(:cleanup).once - - @instance.call(@env) - end end context "cleaning up" do setup do @temp_dir = "foo" @@ -74,28 +49,25 @@ File.stubs(:exist?).returns(true) end should "delete the temporary file if it exists" do File.expects(:unlink).with(@temp_dir).once - @instance.cleanup + @instance.recover(nil) end should "not delete anything if it doesn't exist" do File.stubs(:exist?).returns(false) File.expects(:unlink).never - @instance.cleanup + @instance.recover(nil) end end context "setting up the temporary directory" do setup do @time_now = Time.now.to_i.to_s Time.stubs(:now).returns(@time_now) - @tmp_path = "foo" - @env.env.stubs(:tmp_path).returns(@tmp_path) - - @temp_dir = File.join(@env.env.tmp_path, @time_now) + @temp_dir = @env.env.tmp_path.join(@time_now) FileUtils.stubs(:mkpath) end should "create the temporary directory using the current time" do FileUtils.expects(:mkpath).with(@temp_dir).once