11---
22id : 2607191917
33title : >-
4- Add a dedicated unit test for printInitCatalog
4+ Add dedicated unit tests for printInitCatalog and
5+ setInitUsage
56status : " 🔲"
67model : haiku
78summary : >-
8- printInitCatalog (cmd/mdsmith/init.go) has no
9- TestPrintInitCatalog ; only an e2e subprocess test
10- exercises `mdsmith init --list` . Flagged by the
11- 2026-07-19 audit as an inverted-pyramid tax finding .
9+ printInitCatalog and setInitUsage (cmd/mdsmith/init.go)
10+ have no dedicated unit test ; only e2e subprocess tests
11+ exercise them . Flagged by the 2026-07-19 audit and its
12+ own 3x code-review pass as inverted-pyramid tax findings .
1213---
13- # Add a dedicated unit test for printInitCatalog
14+ # Add dedicated unit tests for printInitCatalog and setInitUsage
1415
1516## Goal
1617
17- Give ` printInitCatalog ` its own unit test so `mdsmith init
18- --list` behavior is locked at the unit layer, not only
19- through the e2e subprocess test .
18+ Give ` printInitCatalog ` and ` setInitUsage ` their own unit
19+ tests. Lock ` mdsmith init --list` and ` --help ` behavior at
20+ the unit layer, not only through e2e subprocess tests .
2021
2122## Background
2223
@@ -39,9 +40,22 @@ found this gap:
3940 writes to an ` io.Writer ` . It needs no subprocess to
4041 exercise.
4142
42- This is ` tax ` , not ` blocker ` . ` printInitCatalog ` is a
43- helper ` runInit ` calls. It is not itself a CLI subcommand
44- entry point, an LSP handler, or a ` rule.Rule ` method.
43+ A follow-up 3x code-review pass on the PR that filed this
44+ plan found the identical shape one function over:
45+
46+ - ` setInitUsage ` in [ init.go] ( ../cmd/mdsmith/init.go ) has
47+ no ` TestSetInitUsage ` anywhere in
48+ [ init_unit_test.go] ( ../cmd/mdsmith/init_unit_test.go ) .
49+ - Its only exercise is the e2e subprocess assertion for
50+ ` mdsmith init --help ` in
51+ [ e2e_coverage_test.go] ( ../cmd/mdsmith/e2e_coverage_test.go ) .
52+ - Same tests.md citation applies: ` setInitUsage ` installs a
53+ closure on a ` *pflag.FlagSet ` and needs no subprocess to
54+ exercise directly.
55+
56+ Both are ` tax ` , not ` blocker ` . Neither is itself a CLI
57+ subcommand entry point, an LSP handler, or a ` rule.Rule `
58+ method — both are helpers ` runInit ` wires up.
4559
4660## Tasks
4761
@@ -51,16 +65,28 @@ entry point, an LSP handler, or a `rule.Rule` method.
5165 ("Starters (mdsmith init --starter <name >):" and "Packs
5266 (mdsmith init --add <name >):") plus at least one known
5367 starter name and one known pack name appear in the output.
54- 2 . Leave the existing e2e ` --list ` test in place — it still
55- covers the full CLI dispatch path — but do not duplicate the
56- catalog-content assertions there beyond a smoke check.
57- 3 . ` go build ./... ` passes.
58- 4 . ` go test ./cmd/mdsmith/... ` passes.
68+ 2 . Add ` TestSetInitUsage ` in
69+ [ init_unit_test.go] ( ../cmd/mdsmith/init_unit_test.go ) ,
70+ building a ` *pflag.FlagSet ` , calling ` setInitUsage ` , then
71+ invoking ` fs.Usage() ` with a captured ` os.Stderr ` (or by
72+ redirecting the closure's writer, whichever the existing
73+ test helpers in this file support) and asserting the
74+ printed text names ` --starter ` , ` --from-markdownlint ` ,
75+ ` --add ` , ` --force ` , and ` --list ` .
76+ 3 . Leave the existing e2e ` --list ` and ` --help ` tests in
77+ place — they still cover the full CLI dispatch path — but
78+ do not duplicate the content assertions there beyond a
79+ smoke check.
80+ 4 . ` go build ./... ` passes.
81+ 5 . ` go test ./cmd/mdsmith/... ` passes.
5982
6083## Acceptance Criteria
6184
6285- [ ] ` TestPrintInitCatalog ` exists in
6386 [ init_unit_test.go] ( ../cmd/mdsmith/init_unit_test.go ) and
6487 exercises ` printInitCatalog ` directly (no subprocess).
88+ - [ ] ` TestSetInitUsage ` exists in
89+ [ init_unit_test.go] ( ../cmd/mdsmith/init_unit_test.go ) and
90+ exercises ` setInitUsage ` directly (no subprocess).
6591- [ ] ` go test ./... ` is green.
6692- [ ] ` mdsmith check . ` is green.
0 commit comments