Problem
AssertBodyEqual short-circuits on an empty body before comparing:
if len(res.BodyBytes) == 0 {
return fmt.Errorf("body: expected %q, missing", expContent)
}
So asserting that a body equals the empty string always fails — and the error message is self-refuting.
Reproduction
$ http-assert --assert-body-eq '' http://127.0.0.1:8791/empty # 204, empty body
[:] HTTP/1.1 204 No Content
- body: expected "", missing
[exit=93]
Related
AssertBodyMatch has the same shape: a pattern that legitimately matches the empty string (e.g. ^$) can never pass.
Affected code
assertions.go — AssertBodyEqual, AssertBodyMatch
Suggested fix
Drop the special-case and compare directly. The "missing" guard only exists to produce a nicer message; it should not change the verdict.
Problem
AssertBodyEqualshort-circuits on an empty body before comparing:So asserting that a body equals the empty string always fails — and the error message is self-refuting.
Reproduction
Related
AssertBodyMatchhas the same shape: a pattern that legitimately matches the empty string (e.g.^$) can never pass.Affected code
assertions.go—AssertBodyEqual,AssertBodyMatchSuggested fix
Drop the special-case and compare directly. The "missing" guard only exists to produce a nicer message; it should not change the verdict.