Skip to content

test(init): add unit tests for printInitCatalog and setInitUsage (plan 2607191917) - #754

Merged
jeduden merged 5 commits into
mainfrom
claude/youthful-knuth-985n00
Jul 25, 2026
Merged

test(init): add unit tests for printInitCatalog and setInitUsage (plan 2607191917)#754
jeduden merged 5 commits into
mainfrom
claude/youthful-knuth-985n00

Conversation

@jeduden

@jeduden jeduden commented Jul 19, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds TestPrintInitCatalog directly exercising printInitCatalog via a bytes.Buffer — no subprocess, asserts both section headers and concrete description text for the okf starter and wordlists pack.
  • Adds TestSetInitUsage directly exercising setInitUsage via a bytes.Buffer injected into the new w io.Writer parameter — no subprocess, asserts the static header flag names and pins fs.PrintDefaults() via the production --force description.
  • Refactors setInitUsage to accept io.Writer (matching printInitCatalog) and calls fs.SetOutput(w) so both the header and PrintDefaults() output flow to the same writer without callers having to align them independently.

Closes plan 2607191917.

Test plan

  • go test ./cmd/mdsmith/... passes
  • TestPrintInitCatalog and TestSetInitUsage appear in output with no subprocess
  • mdsmith check . passes

Generated by Claude Code

claude added 4 commits July 19, 2026 22:05
Direct unit tests for printInitCatalog (bytes.Buffer, no subprocess)
and setInitUsage (pflag.FlagSet + captureStderr, no subprocess), as
required by tests.md's per-function rule. Closes plan 2607191917.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013KgrSLVGA3ioVKvpNkK9ar
…aults in test

setInitUsage now accepts io.Writer (matching printInitCatalog) so the test
can pass a bytes.Buffer directly instead of redirecting the global os.Stderr
through captureStderr. TestSetInitUsage registers --force on the FlagSet and
calls fs.SetOutput(&buf) so fs.PrintDefaults() output also flows into the
buffer, covering the path that was silently empty before.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013KgrSLVGA3ioVKvpNkK9ar
…r in setInitUsage

setInitUsage now calls fs.SetOutput(w) so both the header (fmt.Fprintf)
and the flag list (fs.PrintDefaults) flow to the same writer without
callers having to align them independently. TestSetInitUsage asserts
"overwrite existing .mdsmith.yml" — a string that only PrintDefaults can
emit — so removing that call would now break the test. Also swap
var force / BoolVar(&force) for BoolVar(new(bool)) to drop the dead
variable.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013KgrSLVGA3ioVKvpNkK9ar
… description columns

TestSetInitUsage now registers --force with the actual production description
("Overwrite an existing .mdsmith.yml instead of leaving it unchanged") so
the PrintDefaults pin matches what a real user sees, not an arbitrary stub.

TestPrintInitCatalog adds description/summary assertions ("Open Knowledge
Format bundle config", "Curated no-llm-tells word-lists") so removing the
description column from printInitCatalog's format string would break the test.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013KgrSLVGA3ioVKvpNkK9ar
@codecov

codecov Bot commented Jul 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.69%. Comparing base (bfd0deb) to head (cd3bb67).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
Components Coverage Δ
Go 98.69% <100.00%> (-0.01%) ⬇️
TypeScript 99.54% <ø> (ø)

☔ View full report in Codecov by Harness.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

golangci-lint's errcheck flagged the unchecked return value of
fmt.Fprintf(w, ...) inside the setInitUsage closure. Add the
standard _, _ = discard prefix to match the rest of the file.

Co-Authored-By: Claude <noreply@anthropic.com>
@jeduden jeduden added queue Add to a PR to enqueue it queue:active Applied automatically when a PR is in an active batch and removed queue Add to a PR to enqueue it labels Jul 25, 2026
@jeduden

jeduden commented Jul 25, 2026

Copy link
Copy Markdown
Owner Author

🟢 Merge Queue — picked up

This PR is in the queue and will be batched with other queue-labelled PRs.

Next: No action needed — you'll get another comment when CI starts on the batch. View merge queue run.

@jeduden

jeduden commented Jul 25, 2026

Copy link
Copy Markdown
Owner Author

🔵 Merge Queue — CI running

Merged into batch branch merge-queue/batch-754-1785006212 alongside #756, #758, #762, #764. View CI run.

Next: No action needed — you'll be notified when CI completes.

@jeduden

jeduden commented Jul 25, 2026

Copy link
Copy Markdown
Owner Author

Merge Queue — merged

This PR landed on main via commit 47ace27. CI run that validated the merge.

Next: Done — nothing more to do here.

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