package lock_free import ( "testing" "time" ) func TestQueues(t *testing.T) { cases := []struct { value int duration time.Duration }{ {1, time.Second}, {3, time.Second * 3}, } route := "test" q := NewQueues[struct{}, int, string]() for _, c := range cases { q.Enqueue(route, c.value) } if q.Len(route) != len(cases) { t.Errorf("queue length error, want %d, got %d", len(cases), q.Len(route)) } for range cases { q.Dequeue(route) } for _, c := range cases { q.DelayEnqueue(route, c.value, c.duration) } notify := make(chan int) go func() { for data := range notify { t.Log(data) t.Log(time.Now().Unix()) } }() go q.ContinuousDequeueNotify(route, notify) time.Sleep(time.Second * 5) close(notify) }