Registry / testing / mock-instant

mock-instant

JSON →
library0.6.1rscratesunverified

A simple way to mock std::time::Instant for testing time-dependent code.

# Cargo.toml [dependencies] mock_instant = "0.6.1"
INSTALL
IMPORT
SIG · MOCK-INSTANT
M
mock-instant
testingrustv0.6.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MockClock
use mock_instant::MockClock;

Set and query mock time

use mock_instant::MockClock; use std::time::Duration; fn main() { MockClock::set_time(Duration::from_secs(100)); let now = MockClock::now(); println!("Mock time: {:?}", now); }
Debug
Known issues
gotchaMockClock is global and not thread-safe; tests using it cannot run in parallel
fix
Use #[serial_test::serial] or run tests with --test-threads=1
affects: >=0.6.0
Upgrade
Version history
0.6.1latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
3 hits · last 30 days
node
2
Amazon
1
Resources
mock-instant — cargo add mock-instant · libregistry