Files
gastown/internal/util/process_test.go
Steve Yegge 5e7c5b4728 refactor: Extract processExists to util.ProcessExists (gt-560ge)
Move duplicated processExists function to shared util package:
- Create internal/util/process.go with ProcessExists function
- Add internal/util/process_test.go with basic tests
- Update witness/manager.go to use util.ProcessExists
- Update refinery/manager.go to use util.ProcessExists
- Remove local processExists functions from both files

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 16:16:25 -08:00

26 lines
644 B
Go

package util
import (
"testing"
)
func TestProcessExistsNonExistent(t *testing.T) {
// Using a very high PID that's unlikely to exist
pid := 999999999
if ProcessExists(pid) {
t.Errorf("ProcessExists(%d) = true, want false for non-existent process", pid)
}
}
func TestProcessExistsNegativePID(t *testing.T) {
// Negative PIDs are invalid and should return false or may cause errors
// depending on the platform, so just test that it doesn't panic
_ = ProcessExists(-1)
}
func TestProcessExistsZero(t *testing.T) {
// PID 0 is special (kernel process on Unix)
// Test that we can call it without panicking
_ = ProcessExists(0)
}