Skip to content

refactor: use t.TempDir() instead of os.MkdirTemp#4575

Merged
CoderZhi merged 2 commits intoiotexproject:masterfrom
yuhangcangqian:master
Mar 15, 2025
Merged

refactor: use t.TempDir() instead of os.MkdirTemp#4575
CoderZhi merged 2 commits intoiotexproject:masterfrom
yuhangcangqian:master

Conversation

@yuhangcangqian
Copy link
Contributor

@yuhangcangqian yuhangcangqian commented Mar 8, 2025

Description

TempDir returns a temporary directory for the test to use.The directory is automatically removed when the test and
all its subtests complete. More info https://pkg.go.dev/testing#B.TempDir

Type of change

Please delete options that are not relevant.

  • [] Bug fix (non-breaking change which fixes an issue)
  • [] New feature (non-breaking change which adds functionality)
  • Code refactor or improvement
  • [] Breaking change (fix or feature that would cause a new or changed behavior of existing functionality)
  • [] This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • make test
  • [] fullsync
  • [] Other test (please specify)

Test Configuration:

  • Firmware version:
  • Hardware:
  • Toolchain:
  • SDK:

Checklist:

  • [] My code follows the style guidelines of this project
  • [] I have performed a self-review of my code
  • [] I have commented my code, particularly in hard-to-understand areas
  • [] I have made corresponding changes to the documentation
  • [] My changes generate no new warnings
  • [] I have added tests that prove my fix is effective or that my feature works
  • [] New and existing unit tests pass locally with my changes
  • [] Any dependent changes have been merged and published in downstream modules

Signed-off-by: yuhangcangqian <cuibuwei@qq.com>
@CLAassistant
Copy link

CLAassistant commented Mar 8, 2025

CLA assistant check
All committers have signed the CLA.

@envestcc envestcc requested a review from Copilot March 11, 2025 02:43
Copy link

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.

PR Overview

This pull request refactors the test files to use t.TempDir() instead of os.MkdirTemp(), thereby simplifying temporary directory creation and cleanup in tests.

  • Replaced os.MkdirTemp with t.TempDir() in db_pebble_test.go for TestPebbleDB, TestPebbleDB_Filter, and TestPebbleDB_Foreach.
  • Removed custom cleanup calls using testutil.CleanupPath as t.TempDir() automatically cleans up.

Reviewed Changes

File Description
db/db_pebble_test.go Refactored temporary directory creation in tests
server/itx/server_test.go Updated temporary directory creation for action store

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

@sonarqubecloud
Copy link

@CoderZhi CoderZhi merged commit 538cb7b into iotexproject:master Mar 15, 2025
4 checks passed
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.

5 participants