Releases: corbym/gocrest
v1.1.2
v1.1.1
Splits up the Length, Empty and Nil matchers.
Unfortunately, for matchers that work on arrays, maps or pointers will still require the compiler to be told the type of the underlying value.
E.g.
// nil pointer, actual is declared as `*string`
then.AssertThat(testing, values.actual, is.NilPtr[string]())
//[]int actual
then.AssertThat(stubTestingT, test.actual, has.Length[int](test.expected))
// map
then.AssertThat(t, map[string]bool{"hello": true}, has.MapLength[string, bool](1))
.. but vanilla Nil only works on errors and requires no boilerplate types:
then.AssertThat(stubTestingT, someError, is.Nil())
What's Changed
Full Changelog: v1.1.0...v1.1.1
Async Matchers
Asynchronous Matching (v1.0.8 onwards):
//Reader
then.WithinFiveSeconds(t, func(eventually gocrest.TestingT) {
then.AssertThat(eventually, by.Reading(slowReader, 1024), is.EqualTo([]byte("abcdefghijklmnopqrstuv")))
})
//channels
then.Eventually(t, time.Second*5, time.Second, func(eventually gocrest.TestingT) {
then.AssertThat(eventually, by.Channelling(channel), is.EqualTo(3).Reason("should not fail"))
})
// multiple assertions
then.WithinTenSeconds(t, func(eventually gocrest.TestingT) {
then.AssertThat(eventually, by.Channelling(channel), is.EqualTo(3).Reason("should will fail"))
then.AssertThat(eventually, by.Channelling(channelTwo), is.EqualTo("11").Reason("This is will not fail"))
})
Full Changelog: v1.0.7...v1.0.8
v.1.1.0 - generics
v.1.1.0 - generics
Changes all the matchers to use generics instead of reflection. Some still use a bit of reflection, e.g. TypeName etc.
Other major changes:
-
ValueContaining has been split into StringContaining, MapContaining, MapContainingValues, MapMatchingValues, ArrayContaining and ArrayMatching.
-
No longer panics with unknown types, as types will fail at compile time.
Some idiosyncrasies with the generic types do exist, but this is language specific;- map matchers generally need to know the type of the map key values explicitly or the compiler will complain, e.g.
then.AssertThat(testing, map[string]bool{"hi": true, "bye": true}, has.AllKeys[string, bool]("hi", "bye"))
- has.Length() is likewise pernickety about types being explicit, mainly because it works on both strings and arrays. It needs to know both the type of the array and the array/string type. Confused? me too.
- is.LessThan and is.GreaterThan no longer work on complex types. This is because the complex types do not support the comparison operators (yet, somehow, they could be compared by reflection 🤷 )
- map matchers generally need to know the type of the map key values explicitly or the compiler will complain, e.g.
See the matcher_test.go file for full usage.
What's Changed
New Contributors
Full Changelog: v1.08...v1.1.0
AllOf reports only failed matches
Fixes #3
Full Changelog: v1.0.5...v1.0.6
More matchers and is.Nil fixed
Two more matchers added:
- has.EveryElement(x1...xn) - checks if actual[i] matches corresponding expectation (x[i])
- has.StructWithValues(map[string]*gocrest.Matcher) - checks if actual[key] matches corresponding expectation (x[key])
Bugs fixed:
Go Module added
Added a go module as per https://blog.golang.org/migrating-to-go-modules
More Matchers
Added matchers:
- has.TypeName - checks if an instance has the struct name x where x is a string or a matcher
- shortcut matchers is.True and is.False
Enhancement and bug fix release
Includes:
- has length panicked with nil actual Matt Corby 21/01/2018 20:48
- godoc for AppendActual Matt Corby 21/01/2018 16:40
- anyof and all of now carry actuals over Matt Corby 21/01/2018 16:36
- Length matcher actual was only useful if you know the length of actual
- not now carries the actual over.
Enhancement Release
EqualToIgnoreWhitespace matcher added.