@@ -59,9 +59,7 @@ type Options struct {
59
59
GoogleTokenValidator * idtoken.Validator
60
60
SSHKeygenAlgorithm gitsshkey.Algorithm
61
61
APIRateLimit int
62
- Store database.Store
63
- Pubsub database.Pubsub
64
- LifecycleExecutor * lifecycle.Executor
62
+ Ticker <- chan time.Time
65
63
}
66
64
67
65
// New constructs an in-memory coderd instance and returns
@@ -79,14 +77,8 @@ func New(t *testing.T, options *Options) *codersdk.Client {
79
77
}
80
78
81
79
// This can be hotswapped for a live database instance.
82
- db := options .Store
83
- pubsub := options .Pubsub
84
- if db == nil {
85
- db = databasefake .New ()
86
- }
87
- if pubsub == nil {
88
- pubsub = database .NewPubsubInMemory ()
89
- }
80
+ db := databasefake .New ()
81
+ pubsub := database .NewPubsubInMemory ()
90
82
if os .Getenv ("DB" ) != "" {
91
83
connectionURL , close , err := postgres .Open ()
92
84
require .NoError (t , err )
@@ -107,12 +99,16 @@ func New(t *testing.T, options *Options) *codersdk.Client {
107
99
})
108
100
}
109
101
110
- if options .LifecycleExecutor == nil {
111
- options .LifecycleExecutor = & lifecycle.Executor {}
112
- }
102
+ ctx , cancelFunc := context .WithCancel (context .Background ())
103
+ lifecycleExecutor := lifecycle .NewExecutor (
104
+ ctx ,
105
+ db ,
106
+ slogtest .Make (t , nil ).Named ("lifecycle.executor" ).Leveled (slog .LevelDebug ),
107
+ options .Ticker ,
108
+ )
109
+ go lifecycleExecutor .Run ()
113
110
114
111
srv := httptest .NewUnstartedServer (nil )
115
- ctx , cancelFunc := context .WithCancel (context .Background ())
116
112
srv .Config .BaseContext = func (_ net.Listener ) context.Context {
117
113
return ctx
118
114
}
0 commit comments