Skip to content

Fix test debris from trustedroot integration tests - #10561

Closed
Solver-Team wants to merge 2 commits into
cli:trunkfrom
Solver-Team:fix-trustedroot-test-debris
Closed

Solver-Team wants to merge 2 commits into
cli:trunkfrom
Solver-Team:fix-trustedroot-test-debris

Conversation

@Solver-Team

@Solver-Team Solver-Team commented Mar 7, 2025 •

Copy link
Copy Markdown

The trustedroot integration tests were leaving TUF repository cache files in the working directory. This PR fixes the issue by:

  • Adding a temporary directory mechanism for TUF cache during tests
  • Using a shared testCacheDir variable to manage the temp directory
  • Creating temp directories only during test runs (when GO_INTEGRATION_TEST=1)
  • Adding a CleanupTestCache function to properly remove the temp directory
  • Updating tests to use proper cleanup through deferred functions
  • The changes ensure that no debris files are left behind after running the tests.

Fixes: #10462

Created with Solver

@Solver-Team
Solver-Team requested a review from a team as a code owner March 7, 2025 20:55
// Set the cache path to the provided dir, or a directory owned by the CLI
opts.CachePath = tufMetadataDir.UnwrapOr(filepath.Join(config.CacheDir(), ".sigstore", "root"))
// During tests, use a temporary directory that will be cleaned up
if os.Getenv("GO_INTEGRATION_TEST") == "1" {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This feels like the wrong way to do this. Is it not possible to set the CachePath via the opts instead?

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.

Running github.com/cli/cli/v2/pkg/cmd/attestation/trustedroot tests leaves debris

3 participants