//go:build !windows package version import ( "errors" "os" "path/filepath" "testing" ) func TestUpdateDirectoryAnchorSurvivesLockPathReplacement(t *testing.T) { path := filepath.Join(t.TempDir(), "manager.update.lock") first, err := tryAcquireUpdateLock(path) if err != nil { t.Fatal(err) } t.Cleanup(func() { _ = first.release() }) if err := os.Rename(path, path+".replaced"); err != nil { t.Fatal(err) } if err := os.WriteFile(path, nil, 0600); err != nil { t.Fatal(err) } second, err := tryAcquireUpdateLock(path) if second != nil { _ = second.release() t.Fatal("replacement lock pathname bypassed the active transaction") } if !errors.Is(err, ErrUpdateInProgress) { t.Fatalf("replacement lock attempt returned %v", err) } }