test: prove no read item can outgrow the snapshot unit

The read routes leave out a room, shade, group or linked shade that
doesn't fit the 3 KB unit, without telling the client (KNOWN_ISSUES.md).
test_snapshot_limits fills a snapshot with the largest possible items and
checks every read document written with the real unit is identical to
the same document written with an unlimited one. The largest item, a
shade, is 1,097 bytes. The unit is now SNAPSHOT_UNIT_SIZE in
ModelSnapshot.h, used by Web.cpp and the tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
cjkas 2026-10-17 23:29:04 +02:00
parent 29211630f2
commit 89d3713d86
5 changed files with 153 additions and 6 deletions

View file

@ -128,6 +128,10 @@ enum class snapshot_doc_t : uint8_t {
// (device, radio and firmware details) into the open top-level object.
typedef void (*snapshot_header_t)(JsonFormatter &json, const model_snapshot_t &snap);
// The buffer each room, shade, group and linked shade is formatted into on its
// own. test_snapshot_limits checks the largest possible item of each fits.
#define SNAPSHOT_UNIT_SIZE 3072
// Writes a document from a snapshot a piece at a time for a chunked response.
// Each room, shade, group and linked shade is formatted into unit on its own;
// one that doesn't fit is logged and left out so the JSON stays valid.