返回 DeepSeek-Reasonix
controller_owner_test.go
根目录 / internal / control / controller_owner_test.go
1 package control
2
3 import (
4 "context"
5 "testing"
6 )
7
8 func newOwnedTestController(t testing.TB, options Options) *Controller {
9 t.Helper()
10 controller := New(options)
11 t.Cleanup(func() {
12 controller.Close()
13 // Close only starts teardown; finalizeControllerClose joins the workers
14 // that may still write under SessionDir. Waiting keeps a late Flush from
15 // racing t.TempDir removal, so it is unconditional.
16 <-controller.closeFinalized
17 if options.SessionService == nil {
18 return
19 }
20 // Close an idle retained runtime when this is the final owner. A runtime
21 // still bound by another controller belongs to that controller's cleanup.
22 _ = options.SessionService.CloseAll(context.Background())
23 })
24 return controller
25 }
26
26 lines GO