Use testify in the internal tests - #169
Merged
Merged
Conversation
Assisted-by: Claude:claude-sonnet-5-5 gofumpt goimports staticcheck gremlins
Each subtest builds its own formatter, since Qualifier memoizes the name it assigned per import path. The memoization sequence stays in one subtest. Assisted-by: Claude:claude-sonnet-5-5 gofumpt goimports staticcheck gremlins
Assisted-by: Claude:claude-sonnet-5-5 gofumpt goimports staticcheck gremlins
Assisted-by: Claude:claude-sonnet-5-5 gofumpt goimports staticcheck gremlins
TestImports compared got and want the wrong way round; the expected value now comes first. Assisted-by: Claude:claude-sonnet-5-5 gofumpt goimports staticcheck gremlins
Assisted-by: Claude:claude-sonnet-5-5 gofumpt goimports staticcheck gremlins
Assisted-by: Claude:claude-sonnet-5-5 gofumpt goimports staticcheck gremlins
The snapshot mismatch message had a %s with no argument; it now names the want/ file. Assisted-by: Claude:claude-sonnet-5-5 gofumpt goimports staticcheck gremlins
Assisted-by: Claude:claude-sonnet-5-5 gofumpt goimports staticcheck gremlins
Assisted-by: Claude:claude-sonnet-5-5 gofumpt goimports staticcheck gremlins
Assisted-by: Claude:claude-sonnet-5-5 gofumpt goimports staticcheck gremlins
Assisted-by: Claude:claude-sonnet-5-5 gofumpt goimports staticcheck gremlins
Assisted-by: Claude:claude-sonnet-5-5 gofumpt goimports staticcheck gremlins
Assisted-by: Claude:claude-sonnet-5-5 gofumpt goimports staticcheck gremlins
Assisted-by: Claude:claude-sonnet-5-5 gofumpt goimports staticcheck gremlins
Assisted-by: Claude:claude-sonnet-5-5 gofumpt goimports staticcheck gremlins
Assisted-by: Claude:claude-sonnet-5-5 gofumpt goimports staticcheck gremlins
Assisted-by: Claude:claude-sonnet-5-5 gofumpt goimports staticcheck gremlins
Assisted-by: Claude:claude-sonnet-5-5 gofumpt goimports staticcheck gremlins
Assisted-by: Claude:claude-sonnet-5-5 gofumpt goimports staticcheck gremlins
Assisted-by: Claude:claude-sonnet-5-5 gofumpt goimports staticcheck gremlins
Assisted-by: Claude:claude-sonnet-5-5 gofumpt goimports staticcheck gremlins
Assisted-by: Claude:claude-sonnet-5-5 gofumpt goimports staticcheck gremlins
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.
Converts the tests under
internal/from hand-rolledif got != want { t.Errorf(...) }checks to testify, package by package, and makes the ones that were hard to follow easier to read. Only_test.gofiles change: no non-test file, nothing undercmd/, and no testdata or snapshot archive.Conversion
t.Errorfbecameassert, andt.Fatalbecamerequire, so a check that used to continue still continues and one that stopped still stops.-updatebehavior and file layout.configurations_test.go,header_test.goand other files that already used testify consistently were left alone.TestTypeFormatteris now eight one-behavior subtests, each with its own formatter, covering the nil and output package, the numeric suffix, the memoized name, skipping declared names, same-named packages, the sortedimportdeclaration, and the JSON key order.Coverage and mutation testing
For every internal package I compared per-function
go tool cover -funcoutput before and after. It is identical for all eleven, so no function lost coverage. Gremlins gives the same killed, lived and not-covered counts as before the change:mutationwas run on its main source files only, because each mutant costs a full test suite. The full suite passes with-race -shuffle=on.Tests that checked less than they looked like
Fixed as part of the conversion:
TypeFormatterkeeps the name it assigned could not tell memoization from recomputation; it now also runs after the declared names change.TestReportTrimsasserted nothing; it now asserts that it does not panic.TestWalkActionsOrderandTestWalkActionsNarrowsDotjoined slices into strings before comparing; they now compare the slices.TestNearestStringskipped its suggestion check when nothing matched.TestDecisionRefusesWhatItCannotModelmade an unchecked type assertion that would panic.TestImportspassed got and want the wrong way round.Left as they were, because removing a case would change what is tested:
TestVersionCommandnever checks its error when the CLI version is known.TestTemplateName_ByPathThenMethodrepeats one case verbatim, and one case in that file has a no-op assertion.TestNewTemplateNameshare a name.🤖 Generated with Claude Code