From 6a62ea1b1da0968250b1937bb1481c4b85451eb0 Mon Sep 17 00:00:00 2001 From: Heatherm Huang Date: Tue, 14 Jul 2026 07:45:51 +0800 Subject: [PATCH] test(grok): synchronize refresh candidate fixture --- .../service/token_refresh_service_candidates_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/backend/internal/service/token_refresh_service_candidates_test.go b/backend/internal/service/token_refresh_service_candidates_test.go index d7a192ea5..df0ed3a49 100644 --- a/backend/internal/service/token_refresh_service_candidates_test.go +++ b/backend/internal/service/token_refresh_service_candidates_test.go @@ -4,6 +4,7 @@ import ( "context" "errors" "strings" + "sync" "testing" "time" @@ -14,6 +15,7 @@ import ( type tokenRefreshCandidateRepo struct { AccountRepository + mu sync.Mutex accounts []Account updatedCredentialIDs []int64 setErrorCalls int @@ -24,6 +26,8 @@ type tokenRefreshCandidateRepo struct { } func (r *tokenRefreshCandidateRepo) ListActive(context.Context) ([]Account, error) { + r.mu.Lock() + defer r.mu.Unlock() r.listActiveCalls++ return r.accounts, nil } @@ -66,22 +70,30 @@ func (r *tokenRefreshCandidateRepo) ListOAuthRefreshCandidatePage(_ context.Cont } func (r *tokenRefreshCandidateRepo) UpdateCredentials(_ context.Context, id int64, _ map[string]any) error { + r.mu.Lock() + defer r.mu.Unlock() r.updatedCredentialIDs = append(r.updatedCredentialIDs, id) return nil } func (r *tokenRefreshCandidateRepo) SetError(context.Context, int64, string) error { + r.mu.Lock() + defer r.mu.Unlock() r.setErrorCalls++ return nil } func (r *tokenRefreshCandidateRepo) SetTempUnschedulable(_ context.Context, _ int64, _ time.Time, reason string) error { + r.mu.Lock() + defer r.mu.Unlock() r.setTempUnschedCalls++ r.lastTempUnschedReason = reason return nil } func (r *tokenRefreshCandidateRepo) ClearTempUnschedulable(context.Context, int64) error { + r.mu.Lock() + defer r.mu.Unlock() r.clearTempCalls++ return nil }