Skip to content

Commit

Permalink
Set the "halted" state bag item to true if halted
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Jun 6, 2013
1 parent 51519a2 commit a69167d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions basic_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func (b *BasicRunner) Run(state map[string]interface{}) {
defer step.Cleanup(state)

if action == ActionHalt {
state["halted"] = true
break
}
}
Expand Down
15 changes: 15 additions & 0 deletions basic_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ func TestBasicRunner_Run(t *testing.T) {
if !reflect.DeepEqual(results, expected) {
t.Errorf("unexpected result: %#v", results)
}

// Test no halted or cancelled
if _, ok := data["cancelled"]; ok {
t.Errorf("cancelled should not be in state bag")
}

if _, ok := data["halted"]; ok {
t.Errorf("halted should not be in state bag")
}
}

func TestBasicRunner_Run_Halt(t *testing.T) {
Expand All @@ -58,6 +67,12 @@ func TestBasicRunner_Run_Halt(t *testing.T) {
if !reflect.DeepEqual(results, expected) {
t.Errorf("unexpected result: %#v", results)
}

// Test that it says it is halted
halted := data["halted"].(bool)
if !halted {
t.Errorf("not halted")
}
}

func TestBasicRunner_Cancel(t *testing.T) {
Expand Down

0 comments on commit a69167d

Please sign in to comment.