oauth2: deflake test relying on time.Now values
It was particularly flaky on Windows where time.Now doesn't advance as fast as elsewhere. Change-Id: Ic0b7c3e4c69389009d1e28750be0cd203fa770aa Reviewed-on: https://go-review.googlesource.com/c/157578 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
This commit is contained in:
5
token.go
5
token.go
@@ -118,13 +118,16 @@ func (t *Token) Extra(key string) interface{} {
|
||||
return v
|
||||
}
|
||||
|
||||
// timeNow is time.Now but pulled out as a variable for tests.
|
||||
var timeNow = time.Now
|
||||
|
||||
// expired reports whether the token is expired.
|
||||
// t must be non-nil.
|
||||
func (t *Token) expired() bool {
|
||||
if t.Expiry.IsZero() {
|
||||
return false
|
||||
}
|
||||
return t.Expiry.Round(0).Add(-expiryDelta).Before(time.Now())
|
||||
return t.Expiry.Round(0).Add(-expiryDelta).Before(timeNow())
|
||||
}
|
||||
|
||||
// Valid reports whether t is non-nil, has an AccessToken, and is not expired.
|
||||
|
||||
Reference in New Issue
Block a user