Skip to content

chore: remove stray test artifacts from the source tree#57

Open
kanywst wants to merge 1 commit into
mainfrom
chore/remove-stray-files
Open

chore: remove stray test artifacts from the source tree#57
kanywst wants to merge 1 commit into
mainfrom
chore/remove-stray-files

Conversation

@kanywst

@kanywst kanywst commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Three empty files are tracked in the repository

$ git ls-files -s pkg/certificate/der pkg/certificate/pem pkg/certificate/invalid
100644 e69de29... 0  pkg/certificate/der       # e69de29 = the empty blob
100644 e69de29... 0  pkg/certificate/invalid
100644 e69de29... 0  pkg/certificate/pem

They are leftovers from an older ExportCertificate test that passed the format string as the filename, so it wrote pem, der and invalid into the package directory. The test has since moved to temp files, but the artifacts were committed and never cleaned up. (They arrived, fittingly, in a commit titled "clean up README and test files".)

The same mistake is still live

TestExportLogic writes test_export.pem into internal/model/ on every go test run. It is gitignored, so it has not been committed — but it is the identical bug and would eventually make the identical mess.

Point it at t.TempDir(), and while there, actually assert the certificate lands on disk (the test only checked the popup message, so it would have passed even if the write silently failed).

Verified go test ./... now leaves the working tree clean.

pkg/certificate/der, /pem and /invalid are tracked, zero-byte files. They
are leftovers from an older ExportCertificate test that passed the format
string as the filename, so it wrote "pem", "der" and "invalid" into the
package directory. The test has since moved to temp files, but the
artifacts were committed and stayed.

TestExportLogic still wrote test_export.pem into internal/model on every
run. It is gitignored, so it never got committed, but it is the same
mistake and it would eventually make the same mess. Point it at t.TempDir
and assert the file actually lands there.
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@kanywst, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 13 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 668c2e34-8efd-4dff-8558-82b834ddffdc

📥 Commits

Reviewing files that changed from the base of the PR and between 6f91c87 and 7c3d58c.

📒 Files selected for processing (5)
  • CLAUDE.md
  • internal/model/logic_test.go
  • pkg/certificate/der
  • pkg/certificate/invalid
  • pkg/certificate/pem
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/remove-stray-files

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a CLAUDE.md file to guide AI development and refactors internal/model/logic_test.go to write test exports to a temporary directory instead of leaving artifacts in the package directory. The review feedback suggests shadowing the model variable locally within the subtest to prevent shared state mutation and adding an assertion to ensure the exported certificate file is not empty.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +218 to +227
m = m.handleExportCommand(target)
if m.viewMode != ViewPopup || m.popupType != PopupAlert {
t.Errorf("Expected PopupAlert after export")
}
if !strings.Contains(m.popupMessage, "successfully") {
t.Errorf("Expected success message, got %q", m.popupMessage)
}
if _, err := os.Stat(target); err != nil {
t.Errorf("expected the certificate to be written: %v", err)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

In Go, subtests should be isolated and avoid mutating shared state from the outer scope. Reassigning m directly mutates the shared m variable, which can lead to fragile tests or side effects if more tests are added or if they are run in a different order. Using m := m.handleExportCommand(target) shadows m locally within the subtest, keeping it isolated.

Additionally, since the original issue was about empty files being left behind, we should assert that the written file is not empty (info.Size() > 0) to prevent regressions.

Suggested change
m = m.handleExportCommand(target)
if m.viewMode != ViewPopup || m.popupType != PopupAlert {
t.Errorf("Expected PopupAlert after export")
}
if !strings.Contains(m.popupMessage, "successfully") {
t.Errorf("Expected success message, got %q", m.popupMessage)
}
if _, err := os.Stat(target); err != nil {
t.Errorf("expected the certificate to be written: %v", err)
}
m := m.handleExportCommand(target)
if m.viewMode != ViewPopup || m.popupType != PopupAlert {
t.Errorf("Expected PopupAlert after export")
}
if !strings.Contains(m.popupMessage, "successfully") {
t.Errorf("Expected success message, got %q", m.popupMessage)
}
info, err := os.Stat(target)
if err != nil {
t.Errorf("expected the certificate to be written: %v", err)
} else if info.Size() == 0 {
t.Errorf("expected the written certificate file to be non-empty")
}

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.

1 participant