env.rs |
|
1143 |
fs.rs |
|
18310 |
mock.rs |
Mocking utilities.
Mock data is set on a per-thread basis. [`crate::std::thread`] handles this automatically for
scoped threads, and warns about creating threads otherwise (which won't be able to
automatically share mocked data, but it can be easily done with [`SharedMockData`] when
appropriate).
Mock data is stored using type erasure, with a [`MockKey`] indexing arbitrary values. Use
[`mock_key!`] to define keys and the values to which they map. This approach was taken as a
matter of covenience for programmers, and the resulting creation and consumption APIs are
succinct yet extensible.
Consumers should define keys (and expose them for mockers), and at runtime create a mock key
instance and call [`MockKey::get`] or [`MockKey::try_get`] to retrieve mocked values to use.
Mockers should call [`builder`] to create a builder, [`set`](Builder::set) key/value mappings,
and call [`run`](Builder::run) to execute code with the mock data set. |
8839 |
mock_stub.rs |
Stubs used when mocking isn't enabled. |
905 |
mod.rs |
Standard library wrapper (for mocking in tests).
In general this should always be used rather than `std` directly, and _especially_ when using
`std` functions and types which interact with the runtime host environment.
Note that, in some cases, this wrapper extends the `std` library. Notably, the [`mock`] module
adds mocking functions. |
876 |
net.rs |
|
241 |
path.rs |
We unfortunately have to mock `Path` because of `exists`, `try_exists`, and `metadata`. |
4710 |
process.rs |
|
5550 |
thread.rs |
|
1474 |
time.rs |
|
944 |