mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 17:36:29 +03:00
feat: Mock SystemTime::now() for the tests
Add a new crate `deltachat_time` with a fake `struct SystemTimeTools` for mocking `SystemTime::now()` for test purposes. One still needs to use `std::time::SystemTime` as a struct representing a system time. I think such a minimalistic approach is ok -- even if somebody uses the original `SystemTime::now()` instead of the mock by mistake, that could break only tests but not the program itself. The worst thing that can happen is that tests using `SystemTime::shift()` and checking messages timestamps f.e. wouldn't catch the corresponding bugs, but now we don't have such tests at all which is much worse.
This commit is contained in:
5
Cargo.lock
generated
5
Cargo.lock
generated
@@ -1103,6 +1103,7 @@ dependencies = [
|
||||
"brotli",
|
||||
"chrono",
|
||||
"criterion",
|
||||
"deltachat-time",
|
||||
"deltachat_derive",
|
||||
"email",
|
||||
"encoded-words",
|
||||
@@ -1223,6 +1224,10 @@ dependencies = [
|
||||
"yerpc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "deltachat-time"
|
||||
version = "1.0.0"
|
||||
|
||||
[[package]]
|
||||
name = "deltachat_derive"
|
||||
version = "2.0.0"
|
||||
|
||||
Reference in New Issue
Block a user