fix: Adjust tests
This commit is contained in:
parent
d0d839ea0e
commit
282a07dbec
@ -51,7 +51,7 @@ impl Rustysearch {
|
|||||||
/// version of ``rustysearch`` & zero docs (used in scoring).
|
/// version of ``rustysearch`` & zero docs (used in scoring).
|
||||||
///
|
///
|
||||||
pub fn read_stats(&self) -> std::io::Result<Stats> {
|
pub fn read_stats(&self) -> std::io::Result<Stats> {
|
||||||
let mut stats: Stats;
|
let stats: Stats;
|
||||||
|
|
||||||
if !Path::new(&self.stats_path).exists() {
|
if !Path::new(&self.stats_path).exists() {
|
||||||
stats = Stats {
|
stats = Stats {
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::{thread::{self}, time::{self, Duration}};
|
|
||||||
use rustysearch::{types::Stats, search::Rustysearch};
|
use rustysearch::{types::Stats, search::Rustysearch};
|
||||||
|
|
||||||
const TEN_MILLIS: Duration = time::Duration::from_millis(100);
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_write_new_stats(){
|
fn test_write_new_stats(){
|
||||||
let stats = Stats{
|
let stats = Stats{
|
||||||
@ -19,7 +16,6 @@ mod tests {
|
|||||||
search.setup();
|
search.setup();
|
||||||
|
|
||||||
search.write_stats(stats).unwrap();
|
search.write_stats(stats).unwrap();
|
||||||
thread::sleep(TEN_MILLIS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -32,7 +28,6 @@ mod tests {
|
|||||||
let stats = search.read_stats().unwrap();
|
let stats = search.read_stats().unwrap();
|
||||||
assert_eq!(stats.version, "0.1.0");
|
assert_eq!(stats.version, "0.1.0");
|
||||||
assert_eq!(stats.total_docs, 0);
|
assert_eq!(stats.total_docs, 0);
|
||||||
thread::sleep(TEN_MILLIS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -48,7 +43,6 @@ mod tests {
|
|||||||
search.increment_total_docs();
|
search.increment_total_docs();
|
||||||
let stats = search.read_stats().unwrap();
|
let stats = search.read_stats().unwrap();
|
||||||
assert_eq!(stats.total_docs, 1);
|
assert_eq!(stats.total_docs, 1);
|
||||||
thread::sleep(TEN_MILLIS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -67,7 +61,6 @@ mod tests {
|
|||||||
|
|
||||||
let total_docs = search.get_total_docs();
|
let total_docs = search.get_total_docs();
|
||||||
assert_eq!(total_docs, 1);
|
assert_eq!(total_docs, 1);
|
||||||
thread::sleep(TEN_MILLIS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clean_stats(){
|
fn clean_stats(){
|
||||||
@ -79,6 +72,5 @@ mod tests {
|
|||||||
total_docs: 0,
|
total_docs: 0,
|
||||||
};
|
};
|
||||||
search.write_stats(new_stats).unwrap();
|
search.write_stats(new_stats).unwrap();
|
||||||
thread::sleep(TEN_MILLIS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user