-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Clean up tests, improve coverage
I have been looking at code coverage reports and was surprised at what I saw. For instance, the source code at godfish.go has most of the core functionality for this project and its coverage was 3%! The test coverage is actually a little better than that because those tests live in package ./internal/test. The quickest way to make that look better with the native golang code coverage tooling is to run the stub driver tests twice. Actually improve code coverage for some areas, like the exported funcs in godfish.go and some helper functionality in package internal. This is mostly to test error handling behavior and API boundaries. Refactor ParseMigration tests Change package from internal to internal_test. This makes the filename, migration tests more consistent with all the other tests in this project. Before, it was package internal because it was constructing a literal mutation value. Though, this is unnecessary. Use subtests, rather than table-driven tests. These are easier to isolate if a test fails. Make stub driver tests easier to set up. Now that the go.mod file specifies v1.17, don't need to pass in a DB_DSN env var each time. That was getting annoying. refactor(stub): Remove error fields from stub Driver implementation These error fields aren't of use right now. In the future, might want to expand this type to return a different error for specific methods. This could help test error handling cases that are otherwise hard to set up. refactor(stub): Remove Version implementation A stubbed version is overkill. When looking closer at what's using the stub package, most tests just use the actual version implementation. Adjust remaining callers to use the real Version implementation. refactor: Replace unused unexported error type, runMigrationError
- Loading branch information
1 parent
2982a55
commit 13adafc
Showing
11 changed files
with
393 additions
and
198 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Oops, something went wrong.