Releases: JosiahWitt/ensure
CLI: Internal cleanup refactor
Deletes some unnecessary code (#53).
Make Equals concurrent safe
Any updates to global deep
settings are now wrapped in a mutex to prevent triggering the race detector.
CLI: Fix paths for v2+ packages
If a mock is generated for a v2+ package, it will now be a usable package path. For example, github.com/hello/world/v2
is generated as github.com/hello/world/v2/mock_world
.
Internal changes related to CLI release
Merge pull request #48 from JosiahWitt/cli-v2 CLI mock generation refactor
CLI: Refactored mock generation
Now the ensure CLI is included in the ensure
repo. This release contains a refactor of the ensure mocks generate
command resulting in a huge performance boost. Instead of relying on the mockgen CLI, which generates several tiny programs that use reflection, it leverages Go's AST parsing package.
A few breaking changes to note for the ensure mocks generate
command:
--disable-parallel
flag has been removed, since the CLI doesn't run anything in parallel anymoretidyAfterGenerate
in.ensure.yml
now defaults totrue
instead offalse
ensure generate mocks
alias toensure mocks generate
has been removed
Expose the original *testing.T with ensure.T()
Now calling ensure.T()
returns the type *testing.T
instead of an interface.
Improve silenced panics
Learn more: #46
Nested ensure.New support
Allow created a new instance of ensure with a different testing context when th ensure
package has been shadowed by the ensure
variable.
For example:
ensure := ensure.New(t)
// ...
t.Run("important tests", func(t *testing.T) {
ensure := ensure.New(t)
// ...
})
Add MatchesAllErrors Chainer
To validate than an error is multiple errors, use:
ensure(err).MatchesAllErrors(user.ErrCreateUserFailed, store.ErrPutItemFailed)
Make Equals stricter and add MatchesRegexp chainer
- Now
Equals
treats nil and empty maps and slices as not equal (maybe a slight breaking change, but is safer) MatchesRegexp
chainer added to allow matching strings against regular expressions