Skip to content

test(user-settings): cover Mongo unparseable-timestamp read path#208

Closed
mauripunzueta wants to merge 1 commit into
feat/user-ui-settingsfrom
test/mongo-settings-timestamp-parity
Closed

test(user-settings): cover Mongo unparseable-timestamp read path#208
mauripunzueta wants to merge 1 commit into
feat/user-ui-settingsfrom
test/mongo-settings-timestamp-parity

Conversation

@mauripunzueta

Copy link
Copy Markdown
Contributor

Summary

Adds one MongoDB SettingsStore test that mirrors SQLite's existing get_settings_tolerates_unparseable_timestamp coverage: it plants a row with a valid JSON document but a non-datetime updated_at, then asserts get_settings still returns the document and version — exercising the timestamp-fallback branch (get_datetime(...).map(...).unwrap_or_else(|_| Utc::now())) instead of failing the read.

This closes the last cleanly, deterministically testable gap in mongodb/user_settings.rs, bringing its error-path suite to parity with the SQLite backend. The remaining uncovered lines there are DB-error-injection .map_err arms and concurrency-race branches — the same class the PostgreSQL backend also leaves uncovered — which aren't worth fault-injection or flaky timing tests.

Stacking

Base branch is feat/user-ui-settings (PR #151), not main, because the MongoDB SettingsStore this test targets is introduced by #151 and does not exist on main.

Once #151 merges, this PR will be retargeted to main (and rebased), at which point it picks up full CI. Until then, as a stacked PR (base ≠ main) it does not trigger the HFS CI workflow.

Test plan

  • cargo test -p helios-persistence --features mongodb --test mongodb_tests mongodb_integration_settings_get_tolerates_unparseable_timestamp (runs against a Mongo testcontainer, or HFS_TEST_MONGODB_URL if set; skips gracefully when neither is available).

Add a MongoDB SettingsStore test mirroring SQLite's
get_settings_tolerates_unparseable_timestamp: plant a row with a valid
JSON document but a non-datetime `updated_at`, and assert get_settings
still returns the document and version, exercising the timestamp fallback
branch rather than failing the read.

Stacked on feat/user-ui-settings (PR #151), which introduces the MongoDB
SettingsStore this test targets.
@mauripunzueta

Copy link
Copy Markdown
Contributor Author

Closing — wrong scope. This is a narrow, one-off test of the MongoDB SettingsStore (which only exists in #151), not the reusable, broadly-useful MongoDB test infrastructure that was actually requested. Superseding with a test that branches from main and helps any future code touching the MongoDB backend. Branch kept for now in case we want the parity test inside #151 later.

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.

1 participant