Skip to content

Refactor a common TempDirectory test class #9370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 17, 2025

Conversation

eerhardt
Copy link
Member

DockerComposePublisherTests was using File.Exists and File.Delete, which don't work for directories.

DockerComposePublisherTests was using File.Exists and File.Delete, which don't work for directories.
@eerhardt eerhardt requested review from sebastienros and Copilot May 16, 2025 22:18
@github-actions github-actions bot added the area-integrations Issues pertaining to Aspire Integrations packages label May 16, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@eerhardt eerhardt merged commit 6cbb289 into dotnet:main May 17, 2025
501 of 503 checks passed
@eerhardt eerhardt deleted the SharedTempDirectory branch May 17, 2025 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-integrations Issues pertaining to Aspire Integrations packages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants