Releases: JosiahWitt/ensure
Add Contains chainer and others!
Adds the following chainers:
Contains
- allows checking if a string, list, or array contains somethingDoesNotContain
- allows checking if a string, list, or array does not contain somethingIsNotNil
- to use when you need to ensure something isn'tnil
IsNotEmpty
- to use when you need to ensure something isn't empty
Minor changes to match CLI release
Updates references in this package to match changes from the Ensure CLI v0.1.4 release.
Pretty print actual and expected
Actual and expected are now pretty printed when they are not equal. Strings are quoted, so their formatting doesn't impact the test output. These changes make it easier to tell why a particular equality test is failing.
NEW mock features
Adds the following features to mocks:
- Supports embedding structs in
Mock
struct for sharing groups of mocks between tests (#30) - Allows defining the
NEW
method without parameters for building simple pass-through mocks (#31) - Allows tagging mock fields to be ignored if unused (#32)
See the example in the README for usage.
Support mocks in table driven tests
Mocks are now supported in table driven tests. See the README for an example.
Interface polish with small breaking changes
Breaking changes:
-
Requires Go 1.14+
-
Removes
Fail()
method, and replaces it withFailf(<msg>)
-
Everything now uses
Fatalf
instead ofErrorf
, so tests fail immediately if something goes wrong -
Fails tests if
ensure(...)
is called and is missing chained assertions. For example:ensure(true) // Fails
Add IsEmpty() chained method
Now supports checking for empty arrays, slices, strings, and maps with IsEmpty()
. For example:
ensure([]string{}).IsEmpty()
Fix using imported package and add IsNil()
Now importing the package should not panic. Adds IsNil()
chained method.
Fix import errors
Not committing the mocks caused package import errors.
Initial Release
Support for basic testing.