Refactor a common TempDirectory test class#9370
Merged
eerhardt merged 1 commit intodotnet:mainfrom May 17, 2025
Merged
Conversation
DockerComposePublisherTests was using File.Exists and File.Delete, which don't work for directories.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the temporary directory handling in tests by replacing several ad-hoc local TempDirectory implementations with a shared TempDirectory class.
- Introduces tests/Shared/TempDirectory.cs with a common implementation for creating and cleaning up temporary directories.
- Updates multiple test files to use the new TempDirectory instead of manually creating and deleting directories.
- Removes redundant local implementations of TempDirectory in Kubernetes and Docker tests.
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Shared/TempDirectory.cs | New shared TempDirectory class to create and clean up temp directories for tests. |
| tests/Aspire.Hosting.Tests/PublishAsDockerfileTests.cs | Changed usage of temporary directory from Directory.CreateTempSubdirectory() to the shared TempDirectory. |
| tests/Aspire.Hosting.Tests/MSBuildTests.cs | Updated to use TempDirectory and removed redundant cleanup code. |
| tests/Aspire.Hosting.PostgreSQL.Tests/PostgresFunctionalTests.cs | Refactored temporary directory handling to use TempDirectory. |
| tests/Aspire.Hosting.PostgreSQL.Tests/AddPostgresTests.cs | Updated to use TempDirectory for temporary store path configuration. |
| tests/Aspire.Hosting.MySql.Tests/MySqlFunctionalTests.cs | Refactored TempDirectory usage for persistent lifetime tests. |
| tests/Aspire.Hosting.MySql.Tests/AddMySqlTests.cs | Updated temporary store initialization to use TempDirectory. |
| tests/Aspire.Hosting.Kubernetes.Tests/KubernetesPublisherTests.cs | Removed local TempDirectory class in favor of shared implementation. |
| tests/Aspire.Hosting.Docker.Tests/DockerComposePublisherTests.cs | Removed obsolete local TempDirectory that incorrectly used file deletion logic. |
sebastienros
approved these changes
May 16, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DockerComposePublisherTests was using File.Exists and File.Delete, which don't work for directories.