Skip to content

Commit ad75332

Browse files
authored
Improve tests and fix bugs (#2)
1 parent 806052b commit ad75332

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

middleware_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,23 @@ package buzz
22

33
import (
44
"context"
5-
"errors"
65
"testing"
76
)
87

98
func TestRecoveryMiddleware(t *testing.T) {
10-
bee := NewWorker(&mockTask{
9+
worker := NewWorker(&mockTask{
1110
dofunc: func(ctx context.Context) error {
12-
return errors.New("darn")
11+
panic("darn")
1312
},
1413
}).Use(RecoveryMiddleware)
15-
chain := bee.assembleCallChain()
14+
chain := worker.assembleCallChain()
1615
if chain.exec == nil {
1716
t.Fatal("exec was supposed to be defined but was nil instead")
1817
}
1918
if chain.next == nil {
2019
t.Fatal("chain.next was not supposed to be nil")
2120
}
22-
if err := bee.runChainOnce(context.Background(), chain); err == nil {
21+
if err := worker.runChainOnce(context.Background(), chain); err == nil {
2322
t.Fatal("runChainOnce was supposed to return an error but did not")
2423
}
2524
}

worker.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ func (w *Worker) run(block *sync.WaitGroup) {
6565
case <-ctx.Done():
6666
return
6767
default:
68-
if err := w.runChainOnce(ctx, callChain); err != nil {
69-
return
70-
}
68+
_ = w.runChainOnce(ctx, callChain)
7169
}
7270
}
7371
}

0 commit comments

Comments
 (0)