package lock_free import ( "testing" "time" ) func TestQueuesAck(t *testing.T) { cases := []int{1, 2, 3} route := "test_ack" q := NewQueues[struct{}, int, string]( WithAutoAck(false), WithExpireAutoFail(time.Second), ) for _, c := range cases { q.Enqueue(route, c) } for range cases { q.Dequeue(route) } time.Sleep(2 * time.Second) 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) q.Ack(route, true) } if q.Len(route) != 0 { t.Errorf("queue length error, want %d, got %d", 0, q.Len(route)) } }