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.DelayEnqueue(route, c.value, c.duration) } if q.DelayCount(route) != uint64(len(cases)) { t.Errorf("queue length error, want %d, got %d", len(cases), q.DelayCount(route)) } 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) if q.DelayCount(route) != 0 { t.Errorf("queue length error, want %d, got %d", 0, q.DelayCount(route)) } }