mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
don't depend on timer to increment between ops in unit test
This commit is contained in:
parent
aa7d2721c9
commit
af50c445dd
1 changed files with 12 additions and 9 deletions
|
@ -527,35 +527,38 @@ mod test {
|
||||||
#[test]
|
#[test]
|
||||||
fn undo_mtime_bump() -> Result<()> {
|
fn undo_mtime_bump() -> Result<()> {
|
||||||
let mut col = open_test_collection();
|
let mut col = open_test_collection();
|
||||||
let mtime = col.storage.get_collection_timestamps()?.collection_change;
|
col.storage.db.execute_batch("update col set mod = 0")?;
|
||||||
|
|
||||||
// a no-op change should not bump mtime
|
// a no-op change should not bump mtime
|
||||||
let out = col.set_config_bool(BoolKey::AddingDefaultsToCurrentDeck, true, true)?;
|
let out = col.set_config_bool(BoolKey::AddingDefaultsToCurrentDeck, true, true)?;
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
mtime,
|
col.storage.get_collection_timestamps()?.collection_change.0,
|
||||||
col.storage.get_collection_timestamps()?.collection_change
|
0
|
||||||
);
|
);
|
||||||
assert_eq!(out.changes.had_change(), false);
|
assert_eq!(out.changes.had_change(), false);
|
||||||
|
|
||||||
// if there is an undoable step, mtime should change
|
// if there is an undoable step, mtime should change
|
||||||
let out = col.set_config_bool(BoolKey::AddingDefaultsToCurrentDeck, false, true)?;
|
let out = col.set_config_bool(BoolKey::AddingDefaultsToCurrentDeck, false, true)?;
|
||||||
let new_mtime = col.storage.get_collection_timestamps()?.collection_change;
|
assert_ne!(
|
||||||
assert_ne!(mtime, new_mtime);
|
col.storage.get_collection_timestamps()?.collection_change.0,
|
||||||
|
0
|
||||||
|
);
|
||||||
assert_eq!(out.changes.had_change(), true);
|
assert_eq!(out.changes.had_change(), true);
|
||||||
|
|
||||||
// when skipping undo, mtime should still only be bumped on a change
|
// when skipping undo, mtime should still only be bumped on a change
|
||||||
|
col.storage.db.execute_batch("update col set mod = 0")?;
|
||||||
let out = col.set_config_bool(BoolKey::AddingDefaultsToCurrentDeck, false, false)?;
|
let out = col.set_config_bool(BoolKey::AddingDefaultsToCurrentDeck, false, false)?;
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
new_mtime,
|
col.storage.get_collection_timestamps()?.collection_change.0,
|
||||||
col.storage.get_collection_timestamps()?.collection_change
|
0
|
||||||
);
|
);
|
||||||
assert_eq!(out.changes.had_change(), false);
|
assert_eq!(out.changes.had_change(), false);
|
||||||
|
|
||||||
// op output won't reflect changes were made
|
// op output won't reflect changes were made
|
||||||
let out = col.set_config_bool(BoolKey::AddingDefaultsToCurrentDeck, true, false)?;
|
let out = col.set_config_bool(BoolKey::AddingDefaultsToCurrentDeck, true, false)?;
|
||||||
assert_ne!(
|
assert_ne!(
|
||||||
new_mtime,
|
col.storage.get_collection_timestamps()?.collection_change.0,
|
||||||
col.storage.get_collection_timestamps()?.collection_change
|
0
|
||||||
);
|
);
|
||||||
assert_eq!(out.changes.had_change(), false);
|
assert_eq!(out.changes.had_change(), false);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue