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

View File

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

View File

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