2025-04-23 15:41:13: merge [main:b4757898e54577a90494c93e66bdfa971960a437];

This commit is contained in:
txix committed 2025-04-23 15:41:13 +03:00
1 parent df839dc7d7
commit c6c28112ec
9 files changed
+94 -90

No files matched your search

+1 -2
View File
@@ -1,7 +1,6 @@
package tests_test
import (
"context"
"testing"
"github.com/txix-open/isp-kit/test"
@@ -19,7 +18,7 @@ func TestDailyLimiter(t *testing.T) {
redis = NewRedis(tst)
r = repository.NewDailyLimiter(redis, conf.Redis{Prefix: "test"})
svc = service.NewDailyLimiter(r)
ctx = context.Background()
ctx = t.Context()
req = fake.It[domain.IncrementRequest]()
)
+4 -5
View File
@@ -1,7 +1,6 @@
package tests_test
import (
"context"
"testing"
"time"
@@ -28,7 +27,7 @@ func TestRateLimiter(t *testing.T) {
var (
maxRps = 5
key = "key"
ctx = context.Background()
ctx = t.Context()
)
for i := range maxRps {
resp, err := r.Limit(ctx, key, maxRps)
@@ -89,7 +88,7 @@ func TestRateLimiterInMem(t *testing.T) {
maxRps = 5
reqInterval = time.Second / time.Duration(maxRps)
key = "key"
ctx = context.Background()
ctx = t.Context()
)
for i := range 2 * maxRps {
resp, err := r.LimitInMem(ctx, key, maxRps)
@@ -121,7 +120,7 @@ func BenchmarkRateLimiter(b *testing.B) {
var (
maxRps = 10
key = fake.It[string]()
ctx = context.Background()
ctx = b.Context()
)
b.ResetTimer()
@@ -159,7 +158,7 @@ func BenchmarkRateLimiter2(b *testing.B) {
var (
keys = fake.It[[]string](fake.MinSliceSize(100), fake.MaxSliceSize(100))
ctx = context.Background()
ctx = b.Context()
)
b.ResetTimer()
+2 -3
View File
@@ -1,7 +1,6 @@
package tests_test
import (
"context"
"fmt"
"testing"
"time"
@@ -27,7 +26,7 @@ func TestOne(t *testing.T) {
tst, required := test.New(t)
rcli := NewRedis(tst)
ctx := context.Background()
ctx := t.Context()
r := repository.NewLocker(tst.Logger(), rcli, conf.Redis{Prefix: "testPrefix"}, conf.LockSettings{})
@@ -73,7 +72,7 @@ func TestConcurrency(t *testing.T) {
r := repository.NewLocker(tst.Logger(), redis, conf.Redis{Prefix: "testPrefix"}, conf.LockSettings{})
group, ctx := errgroup.WithContext(context.Background())
group, ctx := errgroup.WithContext(t.Context())
group.SetLimit(32)
for range 10000 {
group.Go(func() error {