You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
go test on a live Windows install deletes the production unit stubs (TestServiceUninstallWindows* missing XDG_STATE_HOME) #351
Running go test ./... — or even just go test ./internal/cli/ — on a machine with a live Berth install silently deletes the production stub files berthd.vbs, berth-gateway.vbs and berth-harbor.vbs from %USERPROFILE%\.local\state\berth\units\.
Mechanism:TestServiceUninstallWindows and TestServiceUninstallWindowsIgnoresEndFailure (internal/cli/service_windows_test.go) call serviceUninstall(..., dryRun=false) without setting XDG_STATE_HOME — every other test in the file does t.Setenv("XDG_STATE_HOME", t.TempDir()). With no XDG variable set, defaultStateDir() falls back to the real user state dir, and the non-dry uninstall path executes os.Remove(unitStubPath(u.Name)) for each unit (service_windows.go:332). The fake ops only fake the schtasks calls, so the real Task Scheduler is never touched — only the real files are deleted.
Repro: any machine with a live install (tasks + units\*.vbs present) → go test ./internal/cli -run TestServiceUninstallWindows → units\ loses its three production stubs.
Fix: add t.Setenv("XDG_STATE_HOME", t.TempDir()) to both tests, matching the rest of the file.
Verified on Windows 11 24H2, berth 0.6.2 (commit e451ba8).
Thanks for the clear report. It's fixed in #352, which is on main and next. Both uninstall tests now set XDG_STATE_HOME to a temp dir. So does TestServiceInstallWindowsCommandFails, which had the same gap. I reproduced it under wine with stubs placed in the profile's state directory. The old tests deleted them. With the fix, the whole internal/cli package leaves them in place.
Activity
T-Crypt commentedon Nov 16, 2026
Thanks for the clear report. It's fixed in #352, which is on
mainandnext. Both uninstall tests now setXDG_STATE_HOMEto a temp dir. So doesTestServiceInstallWindowsCommandFails, which had the same gap. I reproduced it under wine with stubs placed in the profile's state directory. The old tests deleted them. With the fix, the wholeinternal/clipackage leaves them in place.