Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteac766d

Browse files
committed
refactor: do not expose Store in coderdtest.Options
1 parente8495ed commiteac766d

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

‎coderd/autostart/lifecycle/lifecycle_executor_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ func Test_Executor_Run(t *testing.T) {
3333
db=databasefake.New()
3434
le=lifecycle.NewExecutor(cancelCtx,db,log,tickCh)
3535
client=coderdtest.New(t,&coderdtest.Options{
36-
LifecycleExecutor:le,
37-
Store:db,
36+
Ticker:tickCh,
3837
})
3938
// Given: we have a user with a workspace
4039
_=coderdtest.NewProvisionerDaemon(t,client)
@@ -96,8 +95,7 @@ func Test_Executor_Run(t *testing.T) {
9695
db=databasefake.New()
9796
le=lifecycle.NewExecutor(cancelCtx,db,log,tickCh)
9897
client=coderdtest.New(t,&coderdtest.Options{
99-
LifecycleExecutor:le,
100-
Store:db,
98+
Ticker:tickCh,
10199
})
102100
// Given: we have a user with a workspace
103101
_=coderdtest.NewProvisionerDaemon(t,client)

‎coderd/coderdtest/coderdtest.go

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ type Options struct {
5959
GoogleTokenValidator*idtoken.Validator
6060
SSHKeygenAlgorithm gitsshkey.Algorithm
6161
APIRateLimitint
62-
Store database.Store
63-
Pubsub database.Pubsub
64-
LifecycleExecutor*lifecycle.Executor
62+
Ticker<-chan time.Time
6563
}
6664

6765
// New constructs an in-memory coderd instance and returns
@@ -79,14 +77,8 @@ func New(t *testing.T, options *Options) *codersdk.Client {
7977
}
8078

8179
// This can be hotswapped for a live database instance.
82-
db:=options.Store
83-
pubsub:=options.Pubsub
84-
ifdb==nil {
85-
db=databasefake.New()
86-
}
87-
ifpubsub==nil {
88-
pubsub=database.NewPubsubInMemory()
89-
}
80+
db:=databasefake.New()
81+
pubsub:=database.NewPubsubInMemory()
9082
ifos.Getenv("DB")!="" {
9183
connectionURL,close,err:=postgres.Open()
9284
require.NoError(t,err)
@@ -107,12 +99,16 @@ func New(t *testing.T, options *Options) *codersdk.Client {
10799
})
108100
}
109101

110-
ifoptions.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+
golifecycleExecutor.Run()
113110

114111
srv:=httptest.NewUnstartedServer(nil)
115-
ctx,cancelFunc:=context.WithCancel(context.Background())
116112
srv.Config.BaseContext=func(_ net.Listener) context.Context {
117113
returnctx
118114
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp