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

Commitdef317c

Browse files
committed
add test for deleted workspace
1 parentcc1c466 commitdef317c

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

‎coderd/autostart/lifecycle/lifecycle_executor_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,46 @@ func Test_Executor_Autostop_NotEnabled(t *testing.T) {
234234
},5*time.Second,250*time.Millisecond)
235235
}
236236

237+
funcTest_Executor_Workspace_Deleted(t*testing.T) {
238+
t.Parallel()
239+
240+
var (
241+
ctx=context.Background()
242+
errerror
243+
tickCh=make(chan time.Time)
244+
client=coderdtest.New(t,&coderdtest.Options{
245+
LifecycleTicker:tickCh,
246+
})
247+
// Given: we have a user with a workspace
248+
workspace=MustProvisionWorkspace(t,client)
249+
)
250+
251+
// Given: the workspace initially has autostart disabled
252+
require.Empty(t,workspace.AutostopSchedule)
253+
254+
// When: we enable workspace autostart
255+
sched,err:=schedule.Weekly("* * * * *")
256+
require.NoError(t,err)
257+
require.NoError(t,client.UpdateWorkspaceAutostop(ctx,workspace.ID, codersdk.UpdateWorkspaceAutostopRequest{
258+
Schedule:sched.String(),
259+
}))
260+
261+
// Given: workspace is deleted
262+
MustTransitionWorkspace(t,client,workspace.ID,database.WorkspaceTransitionStart,database.WorkspaceTransitionDelete)
263+
264+
// When: the lifecycle executor ticks
265+
gofunc() {
266+
tickCh<-time.Now().UTC().Add(time.Minute)
267+
close(tickCh)
268+
}()
269+
270+
// Then: nothing should happen
271+
require.Never(t,func()bool {
272+
ws:=coderdtest.MustWorkspace(t,client,workspace.ID)
273+
returnws.LatestBuild.Transition!=database.WorkspaceTransitionDelete
274+
},5*time.Second,250*time.Millisecond)
275+
}
276+
237277
funcMustProvisionWorkspace(t*testing.T,client*codersdk.Client) codersdk.Workspace {
238278
t.Helper()
239279
coderdtest.NewProvisionerDaemon(t,client)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp