open-code-review/internal/session/testing.go
kite d84d76b6dc
Some checks are pending
CI / test (push) Waiting to run
fix(session): isolate test sessions to test-sessions subdirectory
Prevent make test from polluting ~/.opencodereview/sessions/ with
thousands of var-folders-* directories by redirecting test session
writes to ~/.opencodereview/test-sessions/.

Introduce a package-level sessionSubDir variable (default "sessions")
and an exported UseTestSessions() function that switches it to
"test-sessions". Each test package that creates sessions calls
UseTestSessions() from init() in an init_test.go file.
2026-06-30 13:23:21 +08:00

10 lines
368 B
Go

package session
// UseTestSessions redirects session persistence to the "test-sessions"
// subdirectory so that test runs do not pollute the real sessions store.
//
// It must be called from init() in a _test.go file or from TestMain,
// before any test goroutines start. It is NOT safe for concurrent use.
func UseTestSessions() {
sessionSubDir = "test-sessions"
}