Cover the current spec with tests#18
Merged
Merged
Conversation
Goal: pin the v1 surface so future refactors can't silently regress. Each test file targets a code path that previously had thin or no coverage. parser/parser_test.go (+8 tests, parser coverage 49.8% → 72.5%): - TestParseInlineForeignKey: inline `col INT REFERENCES other(id)`, auto-name as `<table>_ibfk_<col>` - TestParseColumnAttributes: DEFAULT, COLLATE, COMMENT, ON UPDATE, GENERATED ALWAYS AS … STORED - TestParseSpatialAndFulltextIndex: FULLTEXT KEY / SPATIAL KEY map to model.IndexFulltext / IndexSpatial - TestParseIndexQuirks: prefix length, DESC ordering, multi-column, INVISIBLE, USING BTREE - TestParseCheckConstraint: inline + ALTER TABLE forms, NOT ENFORCED preservation - TestParseMultiColumnPrimaryKey: PK column-list ordering + implicit NOT NULL on PK members - TestParseViewWithColumnList: CREATE VIEW v (a, b) AS … - TestParseTableOptions: ENGINE / CHARSET / COLLATE / COMMENT / AUTO_INCREMENT - TestParseDuplicateRejection: duplicate table / view / column all surface a clear error model/*_test.go (model coverage 0% → 51.6%): - util_test: Ident with safe / reserved-word / unsafe-character / embedded-backtick names; QuoteLiteral with single quote / backslash - view_test: CreateSQL with / without column list / WITH LOCAL CHECK OPTION; CheckOption=NONE suppression; DropSQL; FQVN - index_test: BTREE / UNIQUE multi-col / FULLTEXT / prefix length / DESC / INVISIBLE / expression / comment - foreignkey_test: basic + ON DELETE CASCADE/ON UPDATE SET NULL + multi-column + MATCH FULL options_test.go (root coverage 74.8% → 81.9%): - FilterOptionsMatchName: include / exclude / both / glob patterns - FilterOptionsAfterApply: invalid include and exclude patterns - DropPolicyIsDropAllowed: empty / `all` wildcard / specific / multi - ObjectCount: DBLabel + Summary YAML fixtures: - apply: add_foreign_key, add_index, drop_column (with allow_drop), drop_foreign_key, drop_index, modify_column_type - plan: modify_default, include_filter, disallowed_drop_column, no_changes_with_check (verifies equalCheckDef tolerates backticks), no_changes_with_default_variants - dump: with_index_and_fk Harness extension: planTestCase grows a `disallowed_drops` field so plan fixtures can assert on the `-- skipped: …` lines that go to PlanResult.DisallowedDrops separately from the executable plan SQL. Bug found and fixed: parser/parser.go set Column.Stored to true when opts.Storage == VirtualStorage — i.e. exactly backwards. Now uses StoredStorage. Surfaced by TestParseColumnAttributes. TODO.md: tick the generated-column-expression diff item (the equalExpr plumbing in PR #17 plus the Stored bug fix here together resolve it). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #18 +/- ##
===========================================
+ Coverage 40.20% 54.10% +13.89%
===========================================
Files 25 25
Lines 1634 1634
===========================================
+ Hits 657 884 +227
+ Misses 852 626 -226
+ Partials 125 124 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
winebarrel
added a commit
that referenced
this pull request
May 2, 2026
Copilot review #18 (single comment): line 442 of directive.go still held a literal `\“` (backslash + U+201C "left double quotation mark") where backticks were intended in the doc comment for stripUntilAfterBacktickedName. The previous round of curly-quote cleanup missed this site and another nearby one in the tokenize doc. Both comments are now rephrased without nested-backtick examples so the prose carries the meaning without relying on quoting tricks. No behaviour change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Goal: pin the v1 surface so future refactors can't silently regress. Each test file targets a code path that previously had thin or no coverage.
Coverage delta
myschema(root)parsermodeldiffexpr_test.gofrom PR #17)Bug found and fixed
parser/parser.gosetColumn.Stored = truewhenopts.Storage == VirtualStorage— exactly backwards. Surfaced byTestParseColumnAttributes. Fixed in this PR.Tests added
parser/parser_test.go(+8 tests):TestParseInlineForeignKey— column-levelREFERENCES other(id)shorthandTestParseColumnAttributes— DEFAULT, COLLATE, COMMENT, ON UPDATE, GENERATED ALWAYS AS … STOREDTestParseSpatialAndFulltextIndex— FULLTEXT KEY / SPATIAL KEY →model.IndexFulltext/IndexSpatialTestParseIndexQuirks— prefix length, DESC, multi-column, INVISIBLE, USING BTREETestParseCheckConstraint— inline +ALTER TABLE ADD CONSTRAINT, NOT ENFORCED preservationTestParseMultiColumnPrimaryKey— PK column ordering + implicit NOT NULL on PK membersTestParseViewWithColumnList—CREATE VIEW v (a, b) AS …TestParseTableOptions— ENGINE / CHARSET / COLLATE / COMMENT / AUTO_INCREMENTTestParseDuplicateRejection— duplicate table / view / columnmodel/*_test.go(4 new files): util, view, index, foreignkey — exhaustiveSQL()shape tests including reserved-word quoting, multi-column, MATCH FULL, expression indexes, commentsoptions_test.go(root): FilterOptionsMatchName, FilterOptionsAfterApply, DropPolicyIsDropAllowed, ObjectCount summary formatYAML fixtures (12 new):
apply/: add_foreign_key, add_index, drop_column, drop_foreign_key, drop_index, modify_column_typeplan/: modify_default, include_filter, disallowed_drop_column, no_changes_with_check (verifies equalCheckDef tolerates backticks), no_changes_with_default_variantsdump/: with_index_and_fkHarness extension
planTestCasegrows adisallowed_dropsfield so plan fixtures can assert on the-- skipped: …lines that go toPlanResult.DisallowedDropsseparately from the executable plan SQL.Test plan
make test(parser + diff + catalog + model + YAML harness)make test-scenariogolangci-lint🤖 Generated with Claude Code