mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 21:41:09 +02:00
Refactor: HTTP handler becomes a thin shim over a pure WriteBackup(w, userID, createdAt, iter) function. RowIterator abstracts the store, so tests feed synthetic ChangeRow slices and production feeds StreamAllUserChanges. Zero behavior change in production — same bytes on the wire. Tests (all pass): - TestWriteBackup_Roundtrip: three rows across two apps, assert zip has 2 entries, events.jsonl has 3 JSON lines in order, insert omits fieldTimestamps, update surfaces them, manifest apps are sorted, eventsSha256 equals a recomputed sha of the decompressed body. - TestWriteBackup_EmptyUser: empty userID refused up-front. - TestWriteBackup_NoRows: zero-row export still produces a valid zip with an empty events.jsonl and a manifest with eventCount=0 and a non-empty sha (sha of empty input). - TestWriteBackup_DefaultsSchemaVersionZeroRowsToOne: legacy rows with schema_version=0 clamp to 1 so the manifest never claims a protocol version that never existed. Paired with the vitest zip parser suite on the TS side, this closes the Go-writes / JS-reads round-trip without needing live mana-sync. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| handler.go | ||
| writer.go | ||
| writer_test.go | ||