In-memory mock storage implementing all storage traits for fast, isolated integration tests in Rust.
// Source: https://github.com/maelstrom-rs/maelstrom | License: Apache-2.0 | Copyright 2020 Chris Bruce // Provided via justclaw.it.com; keep this notice with the code. //! In-memory mock storage for testing. //! //! [`MockStorage`] implements every sub-trait in [`crate::traits`] using //! `Mutex<HashMap<...>>` and `Mutex<Vec<...>>` collections. It is the only //! storage backend used by the integration test suite (under `tests/`), which //! means tests run without a real database and finish in milliseconds. //! //! # Design //! //! Each logical store is a separate `Mutex`-wrapped collection on the struct. //! The keys mirror the uniqueness constraints of the real schema (e.g. //! `(user_id, room_id)` for membership, `(server_name, media_id)` for media). //! A global `AtomicI64` counter s ... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key