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)
| 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. |
| 429 | func 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. |
nothing calls this directly
no test coverage detected