fix: unit tests
This commit is contained in:
parent
0ea292b28c
commit
7b598b549c
@ -138,9 +138,9 @@ impl Context {
|
||||
}
|
||||
|
||||
pub async fn load(&mut self) -> Result<(), Box<dyn std::error::Error>> {
|
||||
#[cfg(test)]
|
||||
return Ok(());
|
||||
|
||||
if cfg!(test) {
|
||||
return Ok(());
|
||||
}
|
||||
self.discovery = self.discovery().await?;
|
||||
self.cfg.load(self.to_owned()).await?;
|
||||
self.create_sas().await?;
|
||||
@ -185,8 +185,9 @@ impl Context {
|
||||
return Some(block.ipdata.clone());
|
||||
}
|
||||
} else {
|
||||
let starttime: DateTime<FixedOffset> =
|
||||
DateTime::parse_from_rfc3339(ipdata.date.as_str()).unwrap();
|
||||
let starttime = DateTime::parse_from_rfc3339(ipdata.date.as_str())
|
||||
.unwrap()
|
||||
.with_timezone(&chrono::Local);
|
||||
self.blocklist
|
||||
.entry(ipdata.ip.to_string())
|
||||
.or_insert(BlockIpData {
|
||||
@ -557,6 +558,7 @@ mod test {
|
||||
#[tokio::test]
|
||||
pub async fn test_blocklist_toblock() {
|
||||
let mut ctx = prepare_test_data().await;
|
||||
ctx.gc_blocklist().await;
|
||||
let toblock = ctx.get_blocklist_toblock().await;
|
||||
assert_eq!(toblock.len(), 2);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user