v1.13.0
Features
- New operators:
ErrorIsto check the data is an error and matches a wrapped error (useserrors.Isbehind the scene),Firstto find the first matching item of a slice or an array then compare its content,Grepto reduce a slice or an array before comparing its content,Lastto find the last matching item of a slice or an array then compare its content,Recvto read from a channel and test value;
- rework of
JSONparsing:- introduction of raw strings,
- literal
\n,\r&\taccepted in strings, $^Operator(params...)is possible,"$^Operator(params...)"is possible,Operator(without parenthesis) is possible,- accepts
json.RawMessage;
- anchoring is now possible using
td.Aandtd.Anchor, the generic versions oftd.T.Aandtd.T.Anchor; td.Flattennow accepts an optional function to filter and/or transform the items before flattening them;*td.TgainsAssertandRequiremethods, to be consistent with existingtd.Assertandtd.Require;- introduce
td.Sfunction, to produce strings without needingfmt, shorter to write and following the same calling convention as test names (in other words auto-detectingPrintflike format); - new
TestDeepInGotOKconfig to allow to test go-testdeep operators (is forbidden by default, but useful when go-testdeep is used outside golang tests) includingtd.T.TestDeepInGotOKmethod; tdhttppackage:tdhttp.TestAPIcan now test HTTP responses as a whole (CmpResponse) as well as HTTP trailer (CmpTrailer),tdhttp.PostFormandtdhttp.TestAPI.PostFormnow also accepttdhttp.Qas data.
As usual: enjoy! :)
What's changed in details
- docs(README): v1.12.0 release announce by @maxatome in #212
- fix(doc,tdhttp): typo by @Linkid in #213
- Some refactoring by @maxatome in #214
- docs: fix typo by @maxatome in #215
- Grep, First & Last operators by @maxatome in #216
- refactor: go1.16 required now, so drop support for go1.9 to go1.15 by @maxatome in #221
- feat: add ErrorIs operator by @maxatome in #220
- fix(Recv): timeout can mask expected value by @maxatome in #222
- feat(tdhttp): add TestAPI's CmpResponse & CmpTrailer by @maxatome in #219
- feat: replacing bytes.Buffer instances used only to generate strings with strings.Builder. by @ellisonleao in #224
- feat(JSON): operators possible in JSON strings by @maxatome in #217
- refactor: Replace(a, b, -1) → ReplaceAll(a, b) by @maxatome in #226
- feat: go1.20 introduces slice to array convertibility by @maxatome in #227
- feat(tdhttp): allow usage of tdhttp.Q when using PostForm helpers by @c-roussel in #228
- fix(internal/json): avoid data race by @maxatome in #229
- feat: add TestDeepInGotOK allowing to test td.TestDeep operators by @maxatome in #230
- feat(internal): add (*ctxerr.Error).ErrorWithoutColors method by @maxatome in #231
- feat: add generic functions td.Anchor and td.A, another way to anchor by @maxatome in #232
- ci: test with go1.20 by @maxatome in #233
- style: remove useless comment by @maxatome in #234
- docs: fix README typo by @maxatome in #235
- feat(JSON): accept json.RawMessage as input by @deathiop in #237
- Flatten++ by @maxatome in #236
- chore: cosmetic changes before the release by @maxatome in #238
Full Changelog: v1.12.0...v1.13.0