Skip to content

Commit 252016b

Browse files
committed
style(ratelimit_test.go): add blank lines for readability in mock allowFunc
1 parent f3eaa62 commit 252016b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

internal/middleware/ratelimit_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func TestRateLimit_AllowsUnderLimit(t *testing.T) {
4646
mock := &mockRateLimitService{
4747
allowFunc: func(ctx context.Context, ip, key string, lim int, window time.Duration) (bool, int, time.Time, error) {
4848
requestCount++
49+
4950
remaining := limit - requestCount
5051
if remaining < 0 {
5152
remaining = 0
@@ -103,10 +104,12 @@ func TestRateLimit_DeniesOverLimit(t *testing.T) {
103104
mock := &mockRateLimitService{
104105
allowFunc: func(ctx context.Context, ip, key string, lim int, window time.Duration) (bool, int, time.Time, error) {
105106
requestCount++
107+
106108
remaining := limit - requestCount
107109
if remaining < 0 {
108110
remaining = 0
109111
}
112+
110113
allowed := requestCount <= limit
111114

112115
return allowed, remaining, time.Now().Add(1 * time.Minute), nil
@@ -303,6 +306,7 @@ func TestRateLimit_ExemptIP(t *testing.T) {
303306
mock := &mockRateLimitService{
304307
allowFunc: func(ctx context.Context, ip, key string, limit int, window time.Duration) (bool, int, time.Time, error) {
305308
callCount++
309+
306310
t.Errorf("rate limiter should not be called for exempt IPs")
307311

308312
return false, 0, time.Time{}, nil
@@ -443,6 +447,7 @@ func TestRateLimit_NoMatchingRule(t *testing.T) {
443447
mock := &mockRateLimitService{
444448
allowFunc: func(ctx context.Context, ip, key string, limit int, window time.Duration) (bool, int, time.Time, error) {
445449
callCount++
450+
446451
t.Errorf("rate limiter should not be called when no rule matches")
447452

448453
return false, 0, time.Time{}, nil
@@ -759,10 +764,12 @@ func TestRateLimit_Integration_RealScenario(t *testing.T) {
759764
mock := &mockRateLimitService{
760765
allowFunc: func(ctx context.Context, ip, key string, limit int, window time.Duration) (bool, int, time.Time, error) {
761766
requestCounts[ip]++
767+
762768
remaining := limit - requestCounts[ip]
763769
if remaining < 0 {
764770
remaining = 0
765771
}
772+
766773
allowed := requestCounts[ip] <= limit
767774

768775
return allowed, remaining, time.Now().Add(window), nil

0 commit comments

Comments
 (0)