Enable testpackage golangci-lint linter to enforce testing through public interfaces #121
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.
#119 is going to need a lot of tests to make sure that it didn't break anything.
As pre-work, I want to clean up tests by moving them to a separate
letters_test
package to enforce testing through public interfaces[1][2]. This has already helped me uncover a minor mistake, in whichattachment ContentDisposition
andinline ContentDisposition
were not exported from structs.go and therefore could not be used outside of the package.(This was minor, because
ContentDisposition
is just a string type, so the relevant comparison could still be made by our users, but it was inelegant and defeated the purpose of having theContentDisposition
type.)This PR adds a .golangci.yaml file for the linter and explicitly enables
testpackage
that enforces just that.There is a number of linters that I have left commented out. Those are mainly formatting- and complexity-related. I would like to have them all enabled before letters hits 1.0, but since some of them require reformatting huge chunks of code, I plan to enable them one-by-one in separate PRs.
[1] https://pkg.go.dev/testing
[2] https://jdkaplan.dev/thinkin-logs/2021-10-07/