Files
3x-ui/internal/web/service/xray_process_test_seam.go
T
Sanaei d1c4e0261b chore(node): cover the sync tick's online prune from the job package
The traffic sync's call that drops online sets of nodes it no longer
fetches had no test: a job-package test cannot install an xray process,
so online state was invisible there and removing the call passed.

SetXrayProcessForTest installs a test process for tests in other packages,
the same kind of seam as Manager.SetRuntimeOverride. The new job test runs
a real tick with a disabled node and a deleted one and fails without the
call.
2026-09-15 20:39:32 +02:00

17 lines
528 B
Go

package service
import "github.com/mhsanaei/3x-ui/v3/internal/xray"
// SetXrayProcessForTest installs p as the running process and returns the restore func,
// so tests in other packages can observe online state. Never call it in production.
func SetXrayProcessForTest(p *xray.Process) (restore func()) {
previousProcess, previousResult := xrayState.snapshot()
xrayState.replace(p)
return func() {
xrayState.mu.Lock()
xrayState.process = previousProcess
xrayState.result = previousResult
xrayState.mu.Unlock()
}
}