fix: Adjust tests

This commit is contained in:
Alex Wellnitz 2023-10-24 23:59:35 +02:00
parent d0d839ea0e
commit 282a07dbec
2 changed files with 1 additions and 9 deletions

View File

@ -51,7 +51,7 @@ impl Rustysearch {
/// version of ``rustysearch`` & zero docs (used in scoring).
///
pub fn read_stats(&self) -> std::io::Result<Stats> {
let mut stats: Stats;
let stats: Stats;
if !Path::new(&self.stats_path).exists() {
stats = Stats {

View File

@ -1,10 +1,7 @@
#[cfg(test)]
mod tests {
use std::{thread::{self}, time::{self, Duration}};
use rustysearch::{types::Stats, search::Rustysearch};
const TEN_MILLIS: Duration = time::Duration::from_millis(100);
#[test]
fn test_write_new_stats(){
let stats = Stats{
@ -19,7 +16,6 @@ mod tests {
search.setup();
search.write_stats(stats).unwrap();
thread::sleep(TEN_MILLIS);
}
#[test]
@ -32,7 +28,6 @@ mod tests {
let stats = search.read_stats().unwrap();
assert_eq!(stats.version, "0.1.0");
assert_eq!(stats.total_docs, 0);
thread::sleep(TEN_MILLIS);
}
#[test]
@ -48,7 +43,6 @@ mod tests {
search.increment_total_docs();
let stats = search.read_stats().unwrap();
assert_eq!(stats.total_docs, 1);
thread::sleep(TEN_MILLIS);
}
#[test]
@ -67,7 +61,6 @@ mod tests {
let total_docs = search.get_total_docs();
assert_eq!(total_docs, 1);
thread::sleep(TEN_MILLIS);
}
fn clean_stats(){
@ -79,6 +72,5 @@ mod tests {
total_docs: 0,
};
search.write_stats(new_stats).unwrap();
thread::sleep(TEN_MILLIS);
}
}