Skip to content

test: add test coverage for untested files#388

Open
mwbrooks wants to merge 10 commits intomainfrom
mwbrooks-test-coverage-new-files
Open

test: add test coverage for untested files#388
mwbrooks wants to merge 10 commits intomainfrom
mwbrooks-test-coverage-new-files

Conversation

@mwbrooks
Copy link
Member

@mwbrooks mwbrooks commented Mar 11, 2026

Changelog

  • N/A

Summary

This pull request add unit test coverage for 10 previously untested files across internal packages:

  • internal/api
  • internal/archiveutil
  • internal/cmdutil
  • internal/config
  • internal/goutils
  • internal/image
  • internal/iostreams
  • internal/ioutils
  • internal/prompts

Only test files were changed in this pull request.

Requirements

@mwbrooks mwbrooks added this to the Next Release milestone Mar 11, 2026
@mwbrooks mwbrooks self-assigned this Mar 11, 2026
@mwbrooks mwbrooks added code health M-T: Test improvements and anything that improves code health semver:patch Use on pull requests to describe the release version increment labels Mar 11, 2026
@codecov
Copy link

codecov bot commented Mar 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.97%. Comparing base (8700073) to head (6e3c728).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #388      +/-   ##
==========================================
+ Coverage   65.46%   66.97%   +1.51%     
==========================================
  Files         218      218              
  Lines       18120    18120              
==========================================
+ Hits        11862    12136     +274     
+ Misses       5164     4844     -320     
- Partials     1094     1140      +46     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member Author

@mwbrooks mwbrooks left a comment

Choose a reason for hiding this comment

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

Comments the kind ones 🤾🏻

Comment on lines +30 to +31
// TODO: Refactor to use afero.Fs once ExtractAndWriteFile accepts it. Currently uses t.TempDir() which is safe.
func Test_ExtractAndWriteFile(t *testing.T) {
Copy link
Member Author

Choose a reason for hiding this comment

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

note: I've decided to implement these tests now using the t.TempDir() approach, but I've added a comment to refactor the code being tested to inject afero.Fs so that we can change the tests to be our memory-base FS.

Comment on lines +86 to +87
// TODO: Refactor to use afero.Fs once Copy accepts it. Currently uses t.TempDir() which is safe.
func Test_Copy(t *testing.T) {
Copy link
Member Author

Choose a reason for hiding this comment

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

note: More reminders to refactor this, but these tests are safe to run since they are in the temp directory (just slower).


// TODO: Refactor to use afero.Fs once CopyDirectory accepts it. Currently uses t.TempDir() which is safe.
func Test_CopyDirectory(t *testing.T) {
t.Run("copies directory structure", func(t *testing.T) {
Copy link
Member Author

Choose a reason for hiding this comment

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

note: Not using Table Tests here because each test case needs unique setup. To find a balance, I'm using the t.Run("...") to still group the test cases together in the same spirit as table tests.

@mwbrooks mwbrooks marked this pull request as ready for review March 11, 2026 20:41
@mwbrooks mwbrooks requested a review from a team as a code owner March 11, 2026 20:41
Copy link
Contributor

@srtaalej srtaalej left a comment

Choose a reason for hiding this comment

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

LGTM! thanks for increasing our coverage 🟢 🟢 🟢 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code health M-T: Test improvements and anything that improves code health semver:patch Use on pull requests to describe the release version increment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants