chore: 项目基线(基于 WeKnora 定制版,整理文件忽略规则)
This commit is contained in:
commit
9097ee699d
5769 files changed
+1446466
No files matched your search
@@ -0,0 +1,29 @@
|
||||
package asynqdl
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/hibiken/asynq"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// A panic below RecoverMiddleware reaches the dead-letter callback as an
|
||||
// ordinary error instead of unwinding past it.
|
||||
func TestRecoverMiddleware_PanicReachesDeadLetterCallback(t *testing.T) {
|
||||
repo := &fakeRepo{}
|
||||
var callbackErr error
|
||||
cb := func(_ context.Context, _ *asynq.Task, err error) { callbackErr = err }
|
||||
panicking := asynq.HandlerFunc(func(context.Context, *asynq.Task) error {
|
||||
panic("nil retrieve engine")
|
||||
})
|
||||
h := MiddlewareWithCallback(repo, cb)(RecoverMiddleware()(panicking))
|
||||
|
||||
err := h.ProcessTask(context.Background(), asynq.NewTask("document:process", []byte(`{}`)))
|
||||
|
||||
require.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "document:process panicked")
|
||||
assert.Equal(t, err, callbackErr)
|
||||
assert.Equal(t, 1, repo.rowCount())
|
||||
}
|
||||
Reference in new issue
Block a user