bd sync: 2025-12-23 23:38:57

This commit is contained in:
Steve Yegge
2025-12-23 23:38:57 -08:00
parent 05e10b6759
commit e67f27c092
80 changed files with 7165 additions and 8490 deletions

View File

@@ -245,58 +245,3 @@ func TestGetSocketPath(t *testing.T) {
}
})
}
func TestDetermineSocketPath(t *testing.T) {
t.Run("returns same path passed in", func(t *testing.T) {
testPath := "/tmp/.beads/bd.sock"
result := determineSocketPath(testPath)
if result != testPath {
t.Errorf("determineSocketPath(%q) = %q, want %q", testPath, result, testPath)
}
})
t.Run("preserves empty path", func(t *testing.T) {
result := determineSocketPath("")
if result != "" {
t.Errorf("determineSocketPath(\"\") = %q, want empty string", result)
}
})
}
func TestIsDaemonRunningQuiet(t *testing.T) {
tmpDir := t.TempDir()
pidFile := filepath.Join(tmpDir, "daemon.pid")
t.Run("returns false when PID file does not exist", func(t *testing.T) {
os.Remove(pidFile)
if isDaemonRunningQuiet(pidFile) {
t.Error("expected false when PID file does not exist")
}
})
t.Run("returns false when PID file is invalid", func(t *testing.T) {
if err := os.WriteFile(pidFile, []byte("not-a-number"), 0644); err != nil {
t.Fatalf("failed to create PID file: %v", err)
}
defer os.Remove(pidFile)
if isDaemonRunningQuiet(pidFile) {
t.Error("expected false when PID file contains invalid content")
}
})
t.Run("returns false for non-existent PID", func(t *testing.T) {
// Use a PID that's very unlikely to exist
if err := os.WriteFile(pidFile, []byte("999999999"), 0644); err != nil {
t.Fatalf("failed to create PID file: %v", err)
}
defer os.Remove(pidFile)
if isDaemonRunningQuiet(pidFile) {
t.Error("expected false for non-existent PID")
}
})
}
// Note: TestGetPIDFileForSocket, TestReadPIDFromFile, and TestIsPIDAlive
// are already defined in daemon_basics_test.go