v1.12.0
New features
Struct&SStructcan override model fields in expectedFields, as in:td.Cmp(t, got, td.Struct( Person{ Name: "John Doe", Age: 23, Children: 4, }, td.StructFields{ "> Age": td.Between(40, 45), ">Children": 0, // spaces after ">" are optional }), )
Struct&SStructexpectedFields is now optional or multiple. If multiple, all maps are merged from left to right;- try to detect wrongly defined hooks in
tdsuite@deathiop
Given the 5 hooks: - try to detect possible
tdsuite.Run()misuse, warn the user when it is called with a non-pointer suite, and some key methods are only available via a pointer suite; - add
tdhttp.Optionsfunction &tdhttp.TestAPI.Optionsmethod; Codecan now officially delegate its comparison, using two new kinds of function:func(t *td.T, arg)func(assert, require *td.T, arg)
this way the usage of*td.Tmethods is secure. Note that these functions do not return anything;
- using a
*td.Tinstance asCmp*first parameter now allows to inherit its configuration.is the same as:td.Cmp(td.Require(t), got, 42)
td.Require(t).Cmp(got, 42)
Fixes
Helper()was not called inT.LogTrace,T.ErrorTraceandT.FatalTracemethods. Fixed;UseEqual& anchoring feature didn't play well together. Fixed;- panic when comparing nested maps using private fields as key. Fixed.
Miscellaneous
- enhance & refactor doc comments with new go 1.19 features;
- documentation now uses
anyinstead ofinterface{}; - fix typos.
As usual: enjoy! :)