Skip to content

Commit

Permalink
Improve tests and fix bugs (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
thenorthnate authored Mar 1, 2024
1 parent 806052b commit ad75332
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
9 changes: 4 additions & 5 deletions middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,23 @@ package buzz

import (
"context"
"errors"
"testing"
)

func TestRecoveryMiddleware(t *testing.T) {
bee := NewWorker(&mockTask{
worker := NewWorker(&mockTask{
dofunc: func(ctx context.Context) error {
return errors.New("darn")
panic("darn")
},
}).Use(RecoveryMiddleware)
chain := bee.assembleCallChain()
chain := worker.assembleCallChain()
if chain.exec == nil {
t.Fatal("exec was supposed to be defined but was nil instead")
}
if chain.next == nil {
t.Fatal("chain.next was not supposed to be nil")
}
if err := bee.runChainOnce(context.Background(), chain); err == nil {
if err := worker.runChainOnce(context.Background(), chain); err == nil {
t.Fatal("runChainOnce was supposed to return an error but did not")
}
}
4 changes: 1 addition & 3 deletions worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ func (w *Worker) run(block *sync.WaitGroup) {
case <-ctx.Done():
return
default:
if err := w.runChainOnce(ctx, callChain); err != nil {
return
}
_ = w.runChainOnce(ctx, callChain)
}
}
}
Expand Down

0 comments on commit ad75332

Please sign in to comment.