fix tests

This commit is contained in:
Matthew Hooker 2018-01-22 16:50:14 -08:00
parent 8cd403425e
commit ce4f30c5ae
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1
3 changed files with 12 additions and 16 deletions

View File

@ -4,8 +4,6 @@ import (
"reflect"
"testing"
"time"
"golang.org/x/net/context"
)
func TestBasicRunner_ImplRunner(t *testing.T) {
@ -22,7 +20,7 @@ func TestBasicRunner_Run(t *testing.T) {
stepB := &TestStepAcc{Data: "b"}
r := &BasicRunner{Steps: []Step{stepA, stepB}}
r.Run(context.Background(), data)
r.Run(data)
// Test run data
expected := []string{"a", "b"}
@ -55,7 +53,7 @@ func TestBasicRunner_Run_Halt(t *testing.T) {
stepC := &TestStepAcc{Data: "c"}
r := &BasicRunner{Steps: []Step{stepA, stepB, stepC}}
r.Run(context.Background(), data)
r.Run(data)
// Test run data
expected := []string{"a", "b"}
@ -88,12 +86,12 @@ func TestBasicRunner_Run_Run(t *testing.T) {
stepWait := &TestStepWaitForever{}
r := &BasicRunner{Steps: []Step{stepInt, stepWait}}
go r.Run(context.Background(), new(BasicStateBag))
go r.Run(new(BasicStateBag))
// wait until really running
<-ch
// now try to run aain
r.Run(context.Background(), new(BasicStateBag))
r.Run(new(BasicStateBag))
// should not get here in nominal codepath
t.Errorf("Was able to run an already running BasicRunner")
@ -112,7 +110,7 @@ func TestBasicRunner_Cancel(t *testing.T) {
// cancelling an idle Runner is a no-op
r.Cancel()
go r.Run(context.Background(), data)
go r.Run(data)
// Wait until we reach the sync point
responseCh := <-ch
@ -163,7 +161,7 @@ func TestBasicRunner_Cancel_Special(t *testing.T) {
state := new(BasicStateBag)
state.Put("runner", r)
r.Run(context.Background(), state)
r.Run(state)
// test that state contains cancelled
if _, ok := state.GetOk(StateCancelled); !ok {

View File

@ -1,8 +1,8 @@
package multistep
import (
"context"
"fmt"
"golang.org/x/net/context"
"reflect"
"sync"
)

View File

@ -5,8 +5,6 @@ import (
"reflect"
"testing"
"time"
"golang.org/x/net/context"
)
func TestDebugRunner_Impl(t *testing.T) {
@ -41,7 +39,7 @@ func TestDebugRunner_Run(t *testing.T) {
PauseFn: pauseFn,
}
r.Run(context.Background(), data)
r.Run(data)
// Test data
expected := []string{"a", "TestStepAcc", "b", "TestStepAcc"}
@ -68,12 +66,12 @@ func TestDebugRunner_Run_Run(t *testing.T) {
stepWait := &TestStepWaitForever{}
r := &DebugRunner{Steps: []Step{stepInt, stepWait}}
go r.Run(context.Background(), new(BasicStateBag))
go r.Run(new(BasicStateBag))
// wait until really running
<-ch
// now try to run aain
r.Run(context.Background(), new(BasicStateBag))
r.Run(new(BasicStateBag))
// should not get here in nominal codepath
t.Errorf("Was able to run an already running DebugRunner")
@ -93,7 +91,7 @@ func TestDebugRunner_Cancel(t *testing.T) {
// cancelling an idle Runner is a no-op
r.Cancel()
go r.Run(context.Background(), data)
go r.Run(data)
// Wait until we reach the sync point
responseCh := <-ch
@ -156,7 +154,7 @@ func TestDebugPauseDefault(t *testing.T) {
dr := &DebugRunner{Steps: []Step{
&TestStepAcc{Data: "a"},
}}
dr.Run(context.Background(), new(BasicStateBag))
dr.Run(new(BasicStateBag))
complete <- true
}()