test(clean): CLI e2e test covering all 9 migrations budnled into go test#73
Conversation
Adds cmd/notion-sync/clean_e2e_test.go — a synthetic-seed test that exercises every migration listed in internal/clean's package doc: S3 URL stripping, notion-frozen-at removal, notion-url canonicalization (.md + .json), folderPath separator normalization, trailing newline, syncVersion bump (_database.json + _page.json), and AGENTS.md regen. Test runs the binary via `go run .` against a temp-dir workspace, asserts dry-run is read-only, real-run applies every migration, and a second run is idempotent. No Notion API calls. Ref #66. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Code Review (Pass 1)Warning Verdict: Needs Discussion Action Items
Suggestions
Notes
Review feedback assisted by the critical-code-reviewer skill. |
…ng-arg test
- Add TestMain that builds the notion-sync binary into a temp dir; tests now
exec the prebuilt binary instead of `go run .` (4 compiles → 1).
- Anchor each summary count with the leading "(" or ", " punctuation so
"1 URLs stripped" no longer also matches "11 URLs stripped".
- TestCLI_Clean_MissingFolderArg_ExitOne now asserts the stderr contains
"missing folder path" so the test fails loudly if `clean` ever exits
non-zero for an unrelated reason (build regression, panic).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Review pass 1 — applied changes (
|
…tion
Pass-2 review fixes:
- AGENTS.md assertion now anchors on the exact `<!-- notion-sync-version:
dev -->` stamp the test binary writes (TestMain builds without -ldflags,
so version stays at its source default). Old check only verified "not
v0.0.1" + marker present, so a regression that hardcoded the wrong
version would have passed silently.
- expectMetadataMigrated now asserts databaseId/pageId, title,
lastSyncedAt, and entryCount round-trip unchanged through the
syncVersion bump. The bump goes through Write{Database,Page}Metadata,
which serializes the entire struct — a regression that drops a field
was previously invisible because only url/folderPath/syncVersion were
checked.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Code Review (Pass 2)Note Verdict: Approve Suggestions
Notes
Review feedback assisted by the critical-code-reviewer skill. |
go test
Context
notion-sync cleanis the post-upgrade migration command — it absorbs one-time fixes (S3 URL stripping,notion-frozen-atremoval, URL canonicalization, folderPath normalization, syncVersion bumps, AGENTS.md regen) so routine refreshes produce focused diffs.cleanhad unit coverage ininternal/clean/clean_test.goand a hand-run smoke test, but no end-to-end coverage of the binary's CLI surface: arg parsing, exit codes, the stdout summary text users grep against, or interaction effects across migration types in one pass. PR fix(clean): surface URLs canonicalized in dry-run summary #71 was a recent example of that gap biting (theURLs canonicalizedcount was missing from dry-run output).go test ./...and CI for free, no manual invocation needed. Reframed accordingly in Add CLI-level e2e test for the clean command #66.Changes
cmd/notion-sync/clean_e2e_test.go(~300 lines).internal/clean/clean.go's package doc:entry.mdPDF fieldnotion-frozen-at:lineentry.mdnotion-url:(.md)entry.md"url"(JSON)_database.json+_page.json_database.json+_page.jsonpages/.../My Page.md_database.jsonMy Database/_database.json_page.jsonpages/.../_page.jsonAGENTS.md(v0.0.1)Related to #66.
🤖 Generated with Claude Code