Skip to content

fix: isolate PromptLibraryService from real filesystem in tests#277

Merged
PureWeen merged 1 commit intomainfrom
fix/prompt-edit-followup
Mar 4, 2026
Merged

fix: isolate PromptLibraryService from real filesystem in tests#277
PureWeen merged 1 commit intomainfrom
fix/prompt-edit-followup

Conversation

@PureWeen
Copy link
Copy Markdown
Owner

@PureWeen PureWeen commented Mar 4, 2026

Follow-up to #272.

Fixes a test isolation gap where PromptLibraryService could read/write the real ~/.polypilot/prompts/ directory during tests, and a parallel race between PromptCommandTests and PromptLibraryTests causing flaky failures.

Changes:

  • Add PromptLibraryService.SetUserPromptsDirForTesting() to TestSetup module initializer so tests always start with an isolated temp dir (matches the pattern for CopilotService and RepoManager)
  • Add [Collection("PromptLibrary")] to both PromptCommandTests and PromptLibraryTests to prevent parallel mutation of the process-global _userPromptsDir static field
  • Add PromptLibraryCollection.cs with the [CollectionDefinition]

Without this fix, tests that access PromptLibraryService.UserPromptsDir before an explicit SetUserPromptsDirForTesting call resolve to the real filesystem path.

- Add PromptLibraryService.SetUserPromptsDirForTesting() to TestSetup module
  initializer so tests never read from real ~/.polypilot/prompts/
- Add [Collection("PromptLibrary")] to PromptCommandTests and PromptLibraryTests
  to serialize them and prevent parallel mutation of the static _userPromptsDir
- Add PromptLibraryCollection.cs with the CollectionDefinition

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@PureWeen PureWeen merged commit 0664df9 into main Mar 4, 2026
@PureWeen PureWeen deleted the fix/prompt-edit-followup branch March 4, 2026 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant