| 1 | package boot |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "testing" |
| 6 | |
| 7 | "reasonix/internal/config" |
| 8 | "reasonix/internal/session" |
| 9 | ) |
| 10 | |
| 11 | // withTestSession models the production host boundary explicitly. Boot no |
| 12 | // longer creates a persistence service as a side effect of controller assembly. |
| 13 | func withTestSession(t *testing.T, opts Options) Options { |
| 14 | t.Helper() |
| 15 | sessionDir := opts.SessionDir |
| 16 | if sessionDir == "" { |
| 17 | sessionDir = config.SessionDir() |
| 18 | opts.SessionDir = sessionDir |
| 19 | } |
| 20 | service, err := session.NewService("local", session.NewFilesystemPersistence(session.RootForLegacyDir(sessionDir))) |
| 21 | if err != nil { |
| 22 | t.Fatalf("NewService: %v", err) |
| 23 | } |
| 24 | t.Cleanup(func() { _ = service.CloseAll(context.Background()) }) |
| 25 | opts.SessionService = service |
| 26 | opts.SessionHostID = "local" |
| 27 | return opts |
| 28 | } |
| 29 |