MCPcopy Create free account
hub / github.com/codehamr/codehamr / TestCleanupOldRemovesStaleFile

Function TestCleanupOldRemovesStaleFile

internal/update/update_test.go:429–440  ·  view source on GitHub ↗

TestCleanupOldRemovesStaleFile: the previous Apply's .old must be removed at the next launch so it doesn't accumulate. On Windows .old stays locked until the previous process exits, so cleanup must run at launch, not at Apply's end.

(t *testing.T)

Source from the content-addressed store, hash-verified

427// the next launch so it doesn't accumulate. On Windows .old stays locked until
428// the previous process exits, so cleanup must run at launch, not at Apply's end.
429func TestCleanupOldRemovesStaleFile(t *testing.T) {
430 tmpDir := t.TempDir()
431 exec := filepath.Join(tmpDir, "codehamr")
432 stale := exec + ".old"
433 if err := os.WriteFile(stale, []byte("previous"), 0o755); err != nil {
434 t.Fatal(err)
435 }
436 CleanupOld(exec)
437 if _, err := os.Stat(stale); !os.IsNotExist(err) {
438 t.Fatalf("CleanupOld should remove %s, stat err: %v", stale, err)
439 }
440}
441
442// TestCleanupOldNoopWhenMissing: cleanup must be silent (no error/log/panic)
443// when there is no .old file, the steady state once an update has settled.

Callers

nothing calls this directly

Calls 1

CleanupOldFunction · 0.85

Tested by

no test coverage detected