Skip to content

Commit

Permalink
Remove old test
Browse files Browse the repository at this point in the history
  • Loading branch information
oklahomer committed Jun 2, 2019
1 parent b4ae170 commit d4233f4
Showing 1 changed file with 0 additions and 88 deletions.
88 changes: 0 additions & 88 deletions runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1034,94 +1034,6 @@ func Test_runner_superviseBot(t *testing.T) {
}
}

func Test_runner_superviseBot1(t *testing.T) {
SetupAndRun(func() {
rootCxt := context.Background()
errs := []error{
xerrors.New("first error"),
xerrors.New("second error"),
NewBotNonContinuableError("third error should stop Bot"),
}
alertedErr := make(chan error, len(errs))
terminalErr := xerrors.New("this is the end")
judgeCnt := 0
r := runner{
alerters: &alerters{
&DummyAlerter{
AlertFunc: func(_ context.Context, _ BotType, err error) error {
panic("Panic should not affect other alerters' behavior.")
},
},
&DummyAlerter{
AlertFunc: func(_ context.Context, _ BotType, err error) error {
alertedErr <- err
return nil
},
},
},
superviseError: func(_ BotType, _ error) *SupervisionDirective {
judgeCnt++
if judgeCnt%2 == 0 {
return &SupervisionDirective{
StopBot: true,
AlertingErr: terminalErr,
}
}
return nil
},
}
botCtx, errSupervisor := r.superviseBot(rootCxt, "DummyBotType")

select {
case <-botCtx.Done():
t.Error("Bot context should not be canceled at this point.")

default:
// O.K.

}

// Raise all errors
for _, v := range errs {
errSupervisor(v)
}

// Bot should be canceled
select {
case <-botCtx.Done():
// O.K.

case <-time.NewTimer(10 * time.Second).C:
t.Error("Bot context should be canceled at this point.")

}
if e := botCtx.Err(); e != context.Canceled {
t.Errorf("botCtx.Err() must return context.Canceled, but was %#v", e)
}

// Alerters should be called for BotNonContinuableError and the one causes true return value from alertJudge
time.Sleep(10 * time.Millisecond)
if len(alertedErr) != 2 {
t.Errorf("Alerters are not called as many times as expected: %d", len(alertedErr))
}

// See if a succeeding call block
nonBlocking := make(chan bool)
go func() {
errSupervisor(NewBotNonContinuableError("call after context cancellation should not block"))
nonBlocking <- true
}()
select {
case <-nonBlocking:
// O.K.

case <-time.NewTimer(10 * time.Second).C:
t.Error("Call after context cancellation blocks.")

}
})
}

func Test_registerCommand(t *testing.T) {
SetupAndRun(func() {
command := &DummyCommand{}
Expand Down

0 comments on commit d4233f4

Please sign in to comment.