MCPcopy Create free account
hub / github.com/JordanCoin/codemap / TestIsRunningInvalidPIDInputs

Function TestIsRunningInvalidPIDInputs

watch/state_more_test.go:180–209  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

178}
179
180func TestIsRunningInvalidPIDInputs(t *testing.T) {
181 tests := []struct {
182 name string
183 pidContent string
184 writePID bool
185 }{
186 {name: "missing pid file", writePID: false},
187 {name: "invalid pid format", pidContent: "NaN", writePID: true},
188 {name: "nonexistent pid", pidContent: "999999", writePID: true},
189 }
190
191 for _, tt := range tests {
192 t.Run(tt.name, func(t *testing.T) {
193 root := t.TempDir()
194 codemapDir := filepath.Join(root, ".codemap")
195 if err := os.MkdirAll(codemapDir, 0o755); err != nil {
196 t.Fatal(err)
197 }
198 if tt.writePID {
199 if err := os.WriteFile(filepath.Join(codemapDir, "watch.pid"), []byte(tt.pidContent), 0o644); err != nil {
200 t.Fatal(err)
201 }
202 }
203
204 if IsRunning(root) {
205 t.Fatalf("IsRunning(root=%q, pidContent=%q) = true, want false", root, tt.pidContent)
206 }
207 })
208 }
209}
210
211func TestStopWithoutPIDFileReturnsNoDaemonError(t *testing.T) {
212 root := t.TempDir()

Callers

nothing calls this directly

Calls 1

IsRunningFunction · 0.85

Tested by

no test coverage detected