mirror of
https://github.com/YGGverse/aquatic-crawler.git
synced 2026-03-31 17:15:35 +00:00
implement auto-clean by timeout test
This commit is contained in:
parent
ae4e2e4ba9
commit
c212620bc8
1 changed files with 19 additions and 0 deletions
19
src/index.rs
19
src/index.rs
|
|
@ -80,3 +80,22 @@ impl Index {
|
|||
self.is_changed = false
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
use std::{thread::sleep, time::Duration};
|
||||
|
||||
// test values auto-clean by timeout
|
||||
let mut index = Index::init(2, Some(3), false, false);
|
||||
|
||||
index.insert("h1".to_string(), 0, None, None);
|
||||
sleep(Duration::from_secs(1));
|
||||
index.insert("h2".to_string(), 0, None, None);
|
||||
|
||||
index.refresh();
|
||||
assert_eq!(index.len(), 2);
|
||||
|
||||
sleep(Duration::from_secs(2));
|
||||
index.refresh();
|
||||
assert_eq!(index.len(), 1);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue