From ad753323f709a162c275cf4af8b6e6ed1bb4c201 Mon Sep 17 00:00:00 2001 From: Nathan North Date: Thu, 29 Feb 2024 20:03:09 -0800 Subject: [PATCH] Improve tests and fix bugs (#2) --- middleware_test.go | 9 ++++----- worker.go | 4 +--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/middleware_test.go b/middleware_test.go index 582e1b7..e990258 100644 --- a/middleware_test.go +++ b/middleware_test.go @@ -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") } } diff --git a/worker.go b/worker.go index 2789542..39772cf 100644 --- a/worker.go +++ b/worker.go @@ -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) } } }