Commit Graph

3 Commits

Author SHA1 Message Date
Denis Bilenko c9beddc97a Do not convert nil to 404 2025-02-12 12:54:55 +01:00
Denis Bilenko abea174a6a acc: Simplify writing handlers; support customing headers; fix read body bug
Handlers now receive testserver.Request and return any which could be
- nil (returns 404)
- string / []byte (returns it as is but sets content-type to json or test depending on content)
- object (encodes it as json and sets content-type to json)
- testserver.Response (full control over status, headers)

The config is now using the same testserver.Response struct as handlers, so the same logic applies there.

It is now possible to specify headers in test.toml.

This also fixes a bug with RecordRequest reading the body, not leaving it for the actual handler.
2025-02-12 12:54:55 +01:00
Denis Bilenko 54e16d5f62
Always print warnings and errors; clean up format (#2213)
## Changes
- Print warnings and errors by default.
- Fix ErrAlreadyPrinted not to be logged at Error level.
- Format log messages as "Warn: message" instead of "WARN" to make it
more readable and in-line with the rest of the output.
- Only print attributes (pid, mutator, etc) and time when the overall
level is debug (so --debug output has not changed much).

## Tests
- Existing acceptance tests show how warning messages appear in various
test case.
- Added new test for `--debug` output.
- Add sort_lines.py helper to avoid dependency on 'sort' which is
locale-sensitive.
2025-02-07 11:29:40 +00:00