mirror of
https://github.com/hibiken/asynq.git
synced 2026-07-31 20:03:39 +08:00
test: add coverage for BatchEnqueue error paths
Add tests for all uncovered BatchEnqueueContext error paths: nil task, empty/blank typename, invalid options, group rejection, unique rejection, and broker-down (sleeping broker). Add pipeline error test for rdb.BatchEnqueue via cancelled context, and TestTaskOptions/TestTaskOptionsNil for the new Options() accessor on Task.
This commit is contained in:
@@ -293,6 +293,21 @@ func TestBatchEnqueue(t *testing.T) {
|
||||
t.Errorf("state for scheduled task %s = %q, want %q", s1.ID, state, "scheduled")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("pipeline error from cancelled context", func(t *testing.T) {
|
||||
h.FlushDB(t, r.client)
|
||||
|
||||
msg := h.NewTaskMessage("pipeline_error_task", nil)
|
||||
items := []base.BatchEnqueueItem{{Msg: msg}}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cancel()
|
||||
|
||||
_, err := r.BatchEnqueue(ctx, items)
|
||||
if err == nil {
|
||||
t.Error("BatchEnqueue with cancelled context returned nil error, want non-nil")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestEnqueueQueueCache(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user