Files
wehub-resource-sync a06f331eb8
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:33:42 +08:00

49 lines
1.3 KiB
Go

package daemon
import (
"path/filepath"
"testing"
)
func TestStopIntent_MarkClearRoundtrip(t *testing.T) {
t.Setenv("XDG_CACHE_HOME", t.TempDir())
if StopIntentActive() {
t.Fatal("no marker should exist on a fresh state dir")
}
if err := MarkStopIntent(); err != nil {
t.Fatalf("MarkStopIntent: %v", err)
}
if !StopIntentActive() {
t.Fatal("marker must be active after MarkStopIntent")
}
// Idempotent: a second mark keeps it active, not an error.
if err := MarkStopIntent(); err != nil {
t.Fatalf("second MarkStopIntent: %v", err)
}
if !StopIntentActive() {
t.Fatal("marker must still be active after a repeat mark")
}
ClearStopIntent()
if StopIntentActive() {
t.Fatal("marker must be gone after ClearStopIntent")
}
// Clearing an absent marker is a no-op, not a panic/error.
ClearStopIntent()
if StopIntentActive() {
t.Fatal("clearing twice must leave the marker absent")
}
}
func TestStopIntentMarkerPath_UnderStateDir(t *testing.T) {
t.Setenv("XDG_CACHE_HOME", t.TempDir())
marker := StopIntentMarkerPath()
if filepath.Base(marker) != "daemon.stopped" {
t.Errorf("marker basename = %q, want daemon.stopped", filepath.Base(marker))
}
// Co-located with the rest of the daemon's runtime state.
if filepath.Dir(marker) != filepath.Dir(SpawnLockPath()) {
t.Error("stop-intent marker should be a sibling of the spawn lock")
}
}