chore: remove duplicate validate calls on same oauth token (#11598)

* chore: remove duplicate validate calls on same oauth token
This commit is contained in:
Steven Masley
2024-01-12 14:27:22 -06:00
committed by GitHub
parent 8181c9f349
commit 03ee63931c
4 changed files with 119 additions and 3 deletions

View File

@ -184,6 +184,9 @@ type Options struct {
// under the enterprise license, and can't be imported into AGPL.
ParseLicenseClaims func(rawJWT string) (email string, trial bool, err error)
AllowWorkspaceRenames bool
// NewTicker is used for unit tests to replace "time.NewTicker".
NewTicker func(duration time.Duration) (tick <-chan time.Time, done func())
}
// @title Coder API
@ -208,6 +211,12 @@ func New(options *Options) *API {
if options == nil {
options = &Options{}
}
if options.NewTicker == nil {
options.NewTicker = func(duration time.Duration) (tick <-chan time.Time, done func()) {
ticker := time.NewTicker(duration)
return ticker.C, ticker.Stop
}
}
// Safety check: if we're not running a unit test, we *must* have a Prometheus registry.
if options.PrometheusRegistry == nil && flag.Lookup("test.v") == nil {