Sha256: 13dcb3599a8fa475d18ed8ecb1c2c4cd4fdc57867a2c1f3c5662d4e461b5bf78
Contents?: true
Size: 1.7 KB
Versions: 6
Compression:
Stored size: 1.7 KB
Contents
require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper') class HaltActionTest < Test::Unit::TestCase setup do @runner, @vm, @action = mock_action(Vagrant::Actions::VM::Halt) @runner.stubs(:system).returns(linux_system(@vm)) end context "force?" do should "not force by default" do @action.options[:force] = nil assert !@action.force? end should "force if specified" do @action.options[:force] = true assert @action.force? end end context "executing" do setup do @vm.stubs(:running?).returns(true) @runner.system.stubs(:halt) @vm.stubs(:stop) @vm.stubs(:state).returns(:powered_off) end should "invoke the 'halt' around callback" do @runner.expects(:invoke_around_callback).with(:halt).once @action.execute! end should "halt with the system and NOT force VM to stop if powered off" do @vm.expects(:state).with(true).returns(:powered_off) @runner.system.expects(:halt).once @vm.expects(:stop).never @action.execute! end should "halt with the system and force VM to stop if NOT powered off" do @vm.expects(:state).with(true).returns(:running) @runner.system.expects(:halt).once @vm.expects(:stop).once @action.execute! end should "not call halt on the system if forcing" do @action.stubs(:force).returns(true) @runner.system.expects(:halt).never @action.execute! end should "raise an ActionException if VM is not running" do @vm.stubs(:running?).returns(false) @vm.expects(:stop).never assert_raises(Vagrant::Actions::ActionException) { @action.execute! } end end end
Version data entries
6 entries across 6 versions & 2 rubygems