2
0
mirror of https://github.com/hibiken/asynq.git synced 2025-10-26 11:16:12 +08:00

Add AllQueues method to RDB

This commit is contained in:
Ken Hibino
2020-08-11 05:35:06 -07:00
parent b5caefd663
commit d25090c669
2 changed files with 47 additions and 18 deletions

View File

@@ -16,6 +16,34 @@ import (
"github.com/hibiken/asynq/internal/base"
)
func TestAllQueues(t *testing.T) {
r := setup(t)
tests := []struct {
queues []string
}{
{queues: []string{"default"}},
{queues: []string{"custom1", "custom2"}},
{queues: []string{"default", "custom1", "custom2"}},
{queues: []string{}},
}
for _, tc := range tests {
h.FlushDB(t, r.client)
if err := r.client.SAdd(base.AllQueues, tc.queues...).Err(); err != nil {
t.Fatal("could not initialize all queue set")
}
got, err := r.AllQueues()
if err != nil {
t.Errorf("AllQueues() returned an error: %v", err)
continue
}
if diff := cmp.Diff(tc.queues, got, h.SortStringSliceOpt); diff != nil {
t.Errorf("AllQueues() = %v, want %v; (-want, +got)\n%s", got, tc.queues, diff)
}
}
}
func TestCurrentStats(t *testing.T) {
r := setup(t)
m1 := h.NewTaskMessage("send_email", map[string]interface{}{"subject": "hello"})