mirror of
https://github.com/hibiken/asynq.git
synced 2025-10-04 17:42:01 +08:00
Update RDB.RemoveQueue with specific error types
This commit is contained in:
@@ -3503,6 +3503,7 @@ func TestRemoveQueueError(t *testing.T) {
|
||||
archived map[string][]base.Z
|
||||
qname string // queue to remove
|
||||
force bool
|
||||
match func(err error) bool
|
||||
}{
|
||||
{
|
||||
desc: "removing non-existent queue",
|
||||
@@ -3528,6 +3529,7 @@ func TestRemoveQueueError(t *testing.T) {
|
||||
},
|
||||
qname: "nonexistent",
|
||||
force: false,
|
||||
match: errors.IsQueueNotFound,
|
||||
},
|
||||
{
|
||||
desc: "removing non-empty queue",
|
||||
@@ -3553,6 +3555,7 @@ func TestRemoveQueueError(t *testing.T) {
|
||||
},
|
||||
qname: "custom",
|
||||
force: false,
|
||||
match: errors.IsQueueNotEmpty,
|
||||
},
|
||||
{
|
||||
desc: "force removing queue with active tasks",
|
||||
@@ -3579,6 +3582,7 @@ func TestRemoveQueueError(t *testing.T) {
|
||||
qname: "custom",
|
||||
// Even with force=true, it should error if there are active tasks.
|
||||
force: true,
|
||||
match: func(err error) bool { return errors.CanonicalCode(err) == errors.FailedPrecondition },
|
||||
},
|
||||
}
|
||||
|
||||
@@ -3591,8 +3595,8 @@ func TestRemoveQueueError(t *testing.T) {
|
||||
h.SeedAllArchivedQueues(t, r.client, tc.archived)
|
||||
|
||||
got := r.RemoveQueue(tc.qname, tc.force)
|
||||
if got == nil {
|
||||
t.Errorf("%s;(*RDB).RemoveQueue(%q) = nil, want error", tc.desc, tc.qname)
|
||||
if !tc.match(got) {
|
||||
t.Errorf("%s; returned error didn't match expected value; got=%v", tc.desc, got)
|
||||
continue
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user