Skip to content

Bug fixes, Go 1.23 and dependency upgrade, lint - #54

Merged
steinfletcher merged 9 commits into
masterfrom
maintenance
Sep 3, 2026
Merged

Bug fixes, Go 1.23 and dependency upgrade, lint#54
steinfletcher merged 9 commits into
masterfrom
maintenance

Conversation

@steinfletcher

@steinfletcher steinfletcher commented Sep 3, 2026

Copy link
Copy Markdown
Owner

Summary

Maintenance pass over the library: bug fixes with regression tests, one deliberate behaviour change, three new chain methods, a Go and dependency upgrade, and modernisation. Commits are one change each.

Behaviour change

  • Present now passes (and NotPresent fails) for fields holding false, 0 or "". Any zero value used to be treated as absent, contradicting the documented behaviour of checking presence without evaluating the value. null, empty arrays and empty objects are still absent, and the README now spells this out.

New

  • Len, GreaterThan and LessThan on the assertion chain, so they can be used under Chain and Root.

Bug fixes

  • Len, GreaterThan and LessThan panicked (via reflect.Value.Len) when the expression returned a number or boolean, which aborts the test rather than failing it. They now return an error. Their failure messages were also inverted.
  • Contains, Equal, NotEqual and the JWT assertions formatted non-string values with %s, producing %!s(float64=1) in messages. Errors are now wrapped with %w.
  • Matches discarded the error from evaluating the expression, so invalid JSON, an invalid expression and a missing key were all reported as "no match for pattern". The error is now returned, as the other assertions do. One existing test's expected message changed accordingly.
  • Root("$.items").Equal("[0].id", 1) evaluated $.items.[0].id, which the parser rejects. A dot is now only inserted when the sub-expression does not start with a bracket or dot.
  • http.CopyRequest(nil) panicked and CopyResponse shared header slices with the original.

Upgrade

  • go 1.13go 1.23; apitest v1.5.10 → v1.6.1; testify v1.7.0 → v1.12.1.
  • CI ran on Go 1.13/1.14 with unmaintained actions. It now tests 1.23 and stable on Linux, macOS and Windows with -race, plus a golangci-lint job using the same config as apitest.
  • io/ioutilio, interface{}any, lint clean.

Tests and docs

  • New unit tests for the jsonpath and http packages, which had none.
  • README: apitest.New(handler) examples did not compile (New takes a name); the mocks package was undocumented.

Supersedes the dependency and io/any parts of #53.

🤖 Generated with Claude Code

stein-f and others added 9 commits September 3, 2026 12:52
…scalar

Len, GreaterThan and LessThan called reflect.Value.Len on whatever the
expression returned, which panics for numbers and booleans and so
aborts the test (and any sequence diagram report) rather than failing
it. They now return an error for values that have no length. The
failure messages for GreaterThan and LessThan were also the wrong way
round.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Contains, Equal, NotEqual and the JWT assertions formatted non-string
values with %s, producing messages such as '%!s(float64=1)'. The JWT
error for a malformed token also referred to a 'secret' rather than
the signature. Underlying errors are now wrapped with %w.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Matches discarded the error from evaluating the expression, so an
unparsable body, an invalid expression and a missing key were all
reported as 'no match for pattern'. The error is now returned, in line
with the other assertions; 'no match for pattern' is kept for a JSON
null.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Root always inserted a dot between the root and each sub-expression,
so Root("$.items").Equal("[0].id", 1) evaluated "$.items.[0].id",
which the jsonpath parser rejects. The dot is now only inserted when
the sub-expression does not start with one or with a bracket, and a
trailing dot on the root is tolerated.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
CopyRequest dereferenced a nil request while CopyResponse handled nil,
and CopyResponse shared its header value slices with the original.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The workflow ran on Go 1.13 and 1.14 with actions that are no longer
maintained. It now tests on 1.23 and stable across Linux, macOS and
Windows with the race detector, and runs golangci-lint with the same
configuration as apitest.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…er int

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
apitest.New takes a name, not a handler; the examples now use
apitest.Handler. The badge points at the workflow file, the mocks
package (jsonpath matchers for mock request bodies) is documented, and
the Root section shows bracketed sub-expressions.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@steinfletcher
steinfletcher merged commit 19416de into master Sep 3, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants