test, check: assertive tests, runnable examples, real ActivityConf compatibility check, and CheckError→Error rename#33
Merged
Merged
Conversation
- Remove test/main.go and the corresponding `go run .` step in the CI
testing workflow; everything previously exercised there is now covered
by `go test`.
- Move `Filter`, `protoPkg`, `pathPrefix` into test/main_test.go so the
test directory is self-contained.
- Strengthen assertions in TestLoad / TestCheck / TestCheckCompatibility:
validate Issue.Kind, Message prefixes ("load failed:" /
"custom check failed:"), Workbook/Worksheet names, the exact text
output for the single-issue Check case, and JSON payload keys
("workbook":, "worksheet":, "load failed:, "custom check failed:).
- Mark the generated error.<ext>.go header with "DO NOT EDIT" by passing
doNotEdit=true in generateError, since the whole file is templated and
not meant to be hand-edited. Regenerated test/check/error.check.go to
match.
…String Resolve two lint findings (revive `exported`/stutter and `errname`) on the generated check package without weakening semantics: - CheckError -> Error: avoid the `check.CheckError` stutter at the call site; consumers now use `check.Error`, which is the conventional Go name for a package's primary error type. - Issue.Error() -> Issue.String(): a single Issue is a diagnostic record, not an error value. The aggregate `*Error` is what implements the `error` interface; an individual `*Issue` now satisfies `fmt.Stringer` instead, so `errname` no longer flags it. Updated both code generator templates (error.go.tpl, hub.go.tpl) and regenerated test/check/error.check.go and test/check/hub.check.go. test/main_test.go is updated to use *check.Error in errors.As targets. Verified with `go vet ./...` and `go test ./...` (all green).
wenchy
requested changes
May 26, 2026
| @@ -1,64 +0,0 @@ | |||
| package main | |||
Member
There was a problem hiding this comment.
Do not deprecate it. We can use go Example Tests for usage reference.
wenchy
approved these changes
May 26, 2026
Port the previously deleted test/main.go demo into Go example tests so the canonical Hub.Check / Hub.CheckCompatibility usage stays exercised by `go test` and discoverable via `go doc`. - Example_check: invokes Check on testdata/ with BreakFailedCount(1) so a single deterministic custom-check error is asserted via `// Output:`. - Example_checkCompatibility: invokes CheckCompatibility on testdata/ vs testdata1/ with SkipLoadErrors and BreakFailedCount(10); unwraps the returned *check.Error, sorts issues by (workbook, worksheet, kind), and prints `[kind] workbook/worksheet: <first-line-of-message>` for each issue. Sorting + first-line-only formatting eliminates ordering and prototext map non-determinism, allowing a full `// Output:` assertion over all collected issues.
Replace the placeholder CheckCompatibility method with a real implementation that detects removed item IDs between old and new config snapshots. Update tests and examples to reflect the new behavior and simplify deterministic output handling.
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.
Description
Summary
Overhauls the
checkertest surface and tightens a few generator/runtime rough edges:test/main.goprint-and-eyeball runner with a proper assertivego testsuite.Example_check,Example_checkCompatibility) that double as living docs.CheckError→ErrorandIssue.Error()→Issue.String()for better Go ergonomics.ActivityConf.CheckCompatibility(was a placeholder that dumped two prototexts with non-deterministic map ordering).tableauto pick up CSV load-origin metadata and adds the fixtures needed to exercise it.Details
Tests & examples
test/main.gois deleted;test/main_test.gois rewritten as standardtesting.Tcases coveringHub.Check(text + JSON formats),Hub.CheckCompatibility(old/new snapshot pairs),tableau.Filter,SkipLoadErrors,BreakFailedCount, andWithLoadOptions(load.IgnoreUnknownFields()).test/example_test.goadds two// Output:-asserted examples:Example_checkusesBreakFailedCount(1)to keep output stable at a single issue.Example_checkCompatibilitynarrows the run toItemConf+ActivityConfviatableau.Filter, so output is a single deterministic line anderrcan be printed directly — noerrors.As/ sort / first-line-truncation hacks. Other messagers (e.g.ThemeConf) are filtered out because their load errors carry a multi-line file excerpt..github/workflows/testing.ymldrops the obsoletego test test/main.gostep;go test ./...now covers everything.checkpackage renamecmd/protoc-gen-go-tableau-checker/embed/templates/error.go.tpl,hub.go.tpl) and the regeneratedtest/check/error.check.go/test/check/hub.check.go:CheckError→Error(canonical Go name for an error type wrappingIssues []*Issue).Issue.Error()→Issue.String()(anIssueis a value, not itself an error).*check.Error/Issue.String()instead of*check.CheckError/Issue.Error().Real
ActivityConf.CheckCompatibilitytest/check/test_conf.check.go: replaces the placeholder that unconditionally returned a two-prototext dump with a real check — diff old vs. newItemConf.item_map, collect ids removed in the new snapshot, sort withslices.Sort(Go 1.24), and return a single-line error:main_test.goandExample_checkCompatibilityassert on the full string.Deps & fixtures
go.mod/go.sum: bumptableauto the version exposing CSV load-origin metadata.test/testdata2/{Item#ItemConf,Test#ChapterConf}.csvandtest/testdata3/{Item#ItemConf,Test#ChapterConf}.csvto drive the new compatibility cases across distinct origins.test/proto/item_conf.protoandtest/proto/test_conf.prototo support the fixtures.Test plan
go test ./...— green, including both examples.go vet ./...— clean.Example_checkCompatibilityran 5+ times in a row with stable output.Breaking changes
*check.CheckError→*check.Error,Issue.Error()→Issue.String(). Regenerate to pick up the new names.test/main.goremoved; usego test ./....