Skip to content

Commit abf9f25

Browse files
committed
test(manager): test durationToRenewal calculation
1 parent 934c9f3 commit abf9f25

File tree

2 files changed

+464
-4
lines changed

2 files changed

+464
-4
lines changed

manager/entraid_manager.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,12 @@ func (e *entraidTokenManager) durationToRenewal(t *token.Token) time.Duration {
288288
return 0
289289
}
290290

291-
// Subtract lower bound from time till expiration
292-
timeTillExpiration = timeTillExpiration - lowerBoundMillis
291+
// Calculate time until lower bound
292+
timeUntilLowerBound := timeTillExpiration - lowerBoundMillis
293293

294294
// If refresh would occur after lower bound, use time until lower bound
295-
if timeTillExpiration < timeUntilRefresh {
296-
return time.Duration(timeTillExpiration) * time.Millisecond
295+
if timeUntilRefresh > timeUntilLowerBound {
296+
return time.Duration(timeUntilLowerBound) * time.Millisecond
297297
}
298298

299299
// Otherwise use time until refresh

0 commit comments

Comments
 (0)