Skip to content

Commit b81a67c

Browse files
authored
Fix formatting (#32)
* Fix formatting * Formatter workflow
1 parent d065722 commit b81a67c

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

.github/workflows/go-fmt.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: Go Format
22

33
on:
4-
push:
5-
branches: [main]
64
pull_request_target:
75
branches: [main]
86

@@ -15,11 +13,13 @@ jobs:
1513

1614
steps:
1715
- uses: actions/checkout@v4
16+
with:
17+
ref: ${{ github.head_ref }}
1818

1919
- name: Set up Go
2020
uses: actions/setup-go@v4
2121
with:
22-
go-version: "1.24.3"
22+
go-version: "1.24.5"
2323

2424
- name: Install
2525
run: go install mvdan.cc/gofumpt@latest
@@ -30,6 +30,6 @@ jobs:
3030
- name: Format
3131
run: gofumpt -l -w .
3232

33-
- uses: stefanzweifel/git-auto-commit-action@v5
33+
- uses: stefanzweifel/git-auto-commit-action@v6
3434
with:
3535
commit_message: "Automated formatting"

rotating_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ func TestRotatingTokenBucketLimiterCollisionAvoidance(t *testing.T) {
254254

255255
// After rotation, new seed should resolve collision
256256
tick(rotationRate + 1*time.Millisecond)
257-
257+
258258
// Wait for some token refill as well
259259
tick(2 * time.Second)
260260

@@ -285,7 +285,7 @@ func TestRotatingTokenBucketLimiterTokenPreservation(t *testing.T) {
285285
id := []byte("preservation-test")
286286

287287
// Take some tokens but not all
288-
tokensToTake := int(rotatingBurstCapacity) / 2 // Take half of available calls
288+
tokensToTake := int(rotatingBurstCapacity) / 2 // Take half of available calls
289289
for i := 0; i < tokensToTake; i++ {
290290
if !limiter.TakeToken(id) {
291291
t.Errorf("Should be able to take token %d", i)
@@ -464,11 +464,11 @@ func TestRotatingTokenBucketLimiterDifferentIDs(t *testing.T) {
464464
pair := limiter.load(nowfn())
465465
index1 := pair.checked.index(id1)
466466
index2 := pair.checked.index(id2)
467-
467+
468468
if index1 == index2 {
469469
// Hash collision case - IDs share the same bucket
470470
t.Logf("Hash collision detected: both IDs map to bucket %d", index1)
471-
471+
472472
// With collision, they share tokens from the same bucket
473473
// We can make burstCapacity total calls between both IDs
474474
totalCalls := 0
@@ -484,7 +484,7 @@ func TestRotatingTokenBucketLimiterDifferentIDs(t *testing.T) {
484484
break
485485
}
486486
}
487-
487+
488488
// Both should now be rate limited (sharing exhausted bucket)
489489
if limiter.TakeToken(id1) {
490490
t.Error("id1 should be rate limited after bucket exhaustion")
@@ -495,7 +495,7 @@ func TestRotatingTokenBucketLimiterDifferentIDs(t *testing.T) {
495495
} else {
496496
// No collision case - IDs have independent buckets
497497
t.Logf("No collision: id1 maps to bucket %d, id2 maps to bucket %d", index1, index2)
498-
498+
499499
// Each ID should have independent rate limiting (make burstCapacity calls each)
500500
for i := 0; i < int(rotatingBurstCapacity); i++ {
501501
if !limiter.TakeToken(id1) {
@@ -566,4 +566,4 @@ func BenchmarkRotatingTokenBucketLimiterConcurrent(b *testing.B) {
566566
limiter.TakeToken(id)
567567
}
568568
})
569-
}
569+
}

0 commit comments

Comments
 (0)