Skip to content

Releases: corbym/gocrest

v1.1.1

11 Apr 08:25
Compare
Choose a tag to compare

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

  • attempt to fix/lessen some problems mentioned in issue #9 by @corbym in #10

Full Changelog: v1.1.0...v1.1.1

Async Matchers

03 Apr 15:18
Compare
Choose a tag to compare

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

01 Apr 13:33
c340bb4
Compare
Choose a tag to compare

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 🤷 )

See the matcher_test.go file for full usage.

What's Changed

New Contributors

  • @corbym made their first contribution in #8

Full Changelog: v1.08...v1.1.0

AllOf reports only failed matches

15 Mar 15:36
Compare
Choose a tag to compare

More matchers and is.Nil fixed

21 Dec 14:10
43f86e3
Compare
Choose a tag to compare

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:

#2

Go Module added

26 Nov 15:45
23d5fa6
Compare
Choose a tag to compare

More Matchers

01 Feb 17:11
Compare
Choose a tag to compare

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

21 Jan 21:55
Compare
Choose a tag to compare

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

17 Jan 21:56
Compare
Choose a tag to compare

EqualToIgnoreWhitespace matcher added.

v1.0.0

15 Jan 21:59
a676429
Compare
Choose a tag to compare
Update README.md