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

Function TestIsOwnedDaemonInvalidPIDInputs

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

Source from the content-addressed store, hash-verified

146}
147
148func TestIsOwnedDaemonInvalidPIDInputs(t *testing.T) {
149 tests := []struct {
150 name string
151 pidContent string
152 writePID bool
153 }{
154 {name: "missing pid file", writePID: false},
155 {name: "non numeric pid", pidContent: "not-a-pid", writePID: true},
156 {name: "zero pid", pidContent: "0", writePID: true},
157 {name: "negative pid", pidContent: "-42", writePID: true},
158 }
159
160 for _, tt := range tests {
161 t.Run(tt.name, func(t *testing.T) {
162 root := t.TempDir()
163 codemapDir := filepath.Join(root, ".codemap")
164 if err := os.MkdirAll(codemapDir, 0o755); err != nil {
165 t.Fatal(err)
166 }
167 if tt.writePID {
168 if err := os.WriteFile(filepath.Join(codemapDir, "watch.pid"), []byte(tt.pidContent), 0o644); err != nil {
169 t.Fatal(err)
170 }
171 }
172
173 if IsOwnedDaemon(root) {
174 t.Fatalf("IsOwnedDaemon(root=%q, pidContent=%q) = true, want false", root, tt.pidContent)
175 }
176 })
177 }
178}
179
180func TestIsRunningInvalidPIDInputs(t *testing.T) {
181 tests := []struct {

Callers

nothing calls this directly

Calls 1

IsOwnedDaemonFunction · 0.85

Tested by

no test coverage detected