Skip to content

Simplify tests with T.TempDir#929

Merged
sashabaranov merged 1 commit intosashabaranov:masterfrom
alexandear:refactor/simplify-tests
Jan 31, 2025
Merged

Simplify tests with T.TempDir#929
sashabaranov merged 1 commit intosashabaranov:masterfrom
alexandear:refactor/simplify-tests

Conversation

@alexandear
Copy link
Copy Markdown
Contributor

@alexandear alexandear commented Jan 31, 2025

Describe the change

The PR refactors tests that contain os.MkdirTemp and os.Remove with T.TempDir. That allows to remove 50 lines of test code without harming readability.
Also, enables usetesting to automatically detect this in the future.

Describe your solution

The PR replaces usages of CreateTestDirectory with t.TempDir(). It's not needed to call os.Remove anymore.

Additional context

TempDir returns a temporary directory for the test to use. The directory is automatically removed when the test and all its subtests complete.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 31, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.69%. Comparing base (774fc9d) to head (04e8437).
Report is 79 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #929      +/-   ##
==========================================
+ Coverage   98.46%   98.69%   +0.23%     
==========================================
  Files          24       26       +2     
  Lines        1364     1761     +397     
==========================================
+ Hits         1343     1738     +395     
- Misses         15       16       +1     
- Partials        6        7       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Copy Markdown
Owner

@sashabaranov sashabaranov left a comment

Choose a reason for hiding this comment

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

Great work, thank you so much!

@sashabaranov sashabaranov merged commit 7a2915a into sashabaranov:master Jan 31, 2025
@alexandear alexandear deleted the refactor/simplify-tests branch January 31, 2025 19:05
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.

2 participants