package limiter

import (
	"amocrm/internal/workers/limiter"
	"context"
	"fmt"
	"testing"
	"time"
)

func Test_Limiter(t *testing.T) {
	ctx := context.Background()
	rateLimiter := limiter.NewRateLimiter(ctx, 6, 1500*time.Millisecond)

	go func() {
		count := 1
		for {
			if rateLimiter.Check() {
				fmt.Println("GO", count)
				count++
				continue
			}
			fmt.Println("SLEEP")
			time.Sleep(1500 * time.Millisecond)
		}
	}()

	time.Sleep(20 * time.Second)
}
