Skip to content

Commit cd3888e

Browse files
committed
mutexs;
1 parent 8ac048c commit cd3888e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cmd/lakectl/cmd/token_cacing_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,12 @@ func createSecurityProvider(mockClient *mockExternalLoginClient, initialToken *a
310310
)
311311
}
312312

313+
var testMutex sync.Mutex
314+
313315
func TestLoginOnlyOnce(t *testing.T) {
314316
t.Run("login called only once across multiple requests", func(t *testing.T) {
317+
testMutex.Lock()
318+
defer testMutex.Unlock()
315319
resetGlobalState()
316320
cleanup := setupTestHomeDir(t)
317321
defer cleanup()
@@ -343,6 +347,8 @@ func TestLoginOnlyOnce(t *testing.T) {
343347
// }
344348
// func TestNoLoginWhenTokenIsGiven(t *testing.T) {
345349
t.Run("no login performed when valid token provided initially", func(t *testing.T) {
350+
testMutex.Lock()
351+
defer testMutex.Unlock()
346352
resetGlobalState()
347353
cleanup := setupTestHomeDir(t)
348354
defer cleanup()
@@ -373,6 +379,8 @@ func TestLoginOnlyOnce(t *testing.T) {
373379
// }
374380
// func TestRealInterceptWithGlobalCache2(t *testing.T) {
375381
t.Run("handles login failure gracefully", func(t *testing.T) {
382+
testMutex.Lock()
383+
defer testMutex.Unlock()
376384
resetGlobalState()
377385
cleanup := setupTestHomeDir(t)
378386
defer cleanup()
@@ -397,6 +405,8 @@ func TestLoginOnlyOnce(t *testing.T) {
397405
// }
398406
// func TestRealInterceptWithGlobalCache5(t *testing.T) {
399407
t.Run("token cached via callback and reused after provider recreation", func(t *testing.T) {
408+
testMutex.Lock()
409+
defer testMutex.Unlock()
400410
resetGlobalState()
401411
cleanup := setupTestHomeDir(t)
402412
defer cleanup()

0 commit comments

Comments
 (0)