From 7d320e57dace571ea8fbf0ae242009d265edd77d Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Mon, 10 Jan 2022 22:04:57 +0900 Subject: [PATCH] Don't make medias::tests::clean() panic when file not found --- plume-models/src/medias.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plume-models/src/medias.rs b/plume-models/src/medias.rs index f4761461..1af5f3b6 100644 --- a/plume-models/src/medias.rs +++ b/plume-models/src/medias.rs @@ -400,7 +400,15 @@ pub(crate) mod tests { pub(crate) fn clean(conn: &Conn) { //used to remove files generated by tests for media in Media::list_all_medias(conn).unwrap() { - media.delete(conn).unwrap(); + if let Some(err) = media.delete(conn).err() { + match &err { + Error::Io(e) => match e.kind() { + std::io::ErrorKind::NotFound => (), + _ => panic!("{:?}", err), + }, + _ => panic!("{:?}", err), + } + } } }