Skip to content

Commit 81eb3f4

Browse files
authored
fix: flaky integration test (#2834)
* disable cache * simpler fix
1 parent cdf12a4 commit 81eb3f4

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

pkg/auth/token/token_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"os"
99
"testing"
10+
"time"
1011

1112
"github.com/google/uuid"
1213
"github.com/stretchr/testify/assert"
@@ -111,6 +112,10 @@ func TestRevokeTenantToken(t *testing.T) {
111112
t.Fatal(err.Error())
112113
}
113114

115+
// With CACHE_DURATION=0 the repo cache uses a very short TTL (1ms).
116+
// Sleep briefly to ensure any cached token entry expires before re-validation.
117+
time.Sleep(5 * time.Millisecond)
118+
114119
// validate the token again
115120
_, _, err = jwtManager.ValidateTenantToken(context.Background(), token.Token)
116121

pkg/repository/cache/cache.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func New(duration time.Duration) *Cache {
3939
// consider a duration of 0 a very short expiry instead of no expiry
4040
duration = 1 * time.Millisecond
4141
}
42+
4243
return &Cache{
4344
expiration: duration,
4445
cache: cache.NewTTL[string, interface{}](),

0 commit comments

Comments
 (0)