chore: executor: add unit test, rename LifecycleTicker (#1420)

* chore: add a unit test to ensure correct behaviour with multiple coderd replicas
* nit: rename LifecycleTicker to AutobuildTicker
This commit is contained in:
Cian Johnston
2022-05-13 17:14:24 +01:00
committed by GitHub
parent 89e44da899
commit 4ab7a41f08
2 changed files with 68 additions and 13 deletions

View File

@ -61,7 +61,7 @@ type Options struct {
GoogleTokenValidator *idtoken.Validator
SSHKeygenAlgorithm gitsshkey.Algorithm
APIRateLimit int
LifecycleTicker <-chan time.Time
AutobuildTicker <-chan time.Time
}
// New constructs an in-memory coderd instance and returns
@ -77,9 +77,9 @@ func New(t *testing.T, options *Options) *codersdk.Client {
options.GoogleTokenValidator, err = idtoken.NewValidator(ctx, option.WithoutAuthentication())
require.NoError(t, err)
}
if options.LifecycleTicker == nil {
if options.AutobuildTicker == nil {
ticker := make(chan time.Time)
options.LifecycleTicker = ticker
options.AutobuildTicker = ticker
t.Cleanup(func() { close(ticker) })
}
@ -111,7 +111,7 @@ func New(t *testing.T, options *Options) *codersdk.Client {
ctx,
db,
slogtest.Make(t, nil).Named("autobuild.executor").Leveled(slog.LevelDebug),
options.LifecycleTicker,
options.AutobuildTicker,
)
lifecycleExecutor.Run()