diff --git a/packages/backend-rs/src/misc/get_image_size.rs b/packages/backend-rs/src/misc/get_image_size.rs index 4cab76b8ad..9b3e20171c 100644 --- a/packages/backend-rs/src/misc/get_image_size.rs +++ b/packages/backend-rs/src/misc/get_image_size.rs @@ -123,8 +123,7 @@ mod unit_test { let gif_url = "https://firefish.dev/firefish/firefish/-/raw/b9c3dfbd3d473cb2cee20c467eeae780bc401271/packages/backend/test/resources/anime.gif"; let mp3_url = "https://firefish.dev/firefish/firefish/-/blob/5891a90f71a8b9d5ea99c683ade7e485c685d642/packages/backend/assets/sounds/aisha/1.mp3"; - // Delete caches in case you run this test multiple times - #[cfg(not(feature = "ci"))] + // delete caches in case you run this test multiple times cache::delete_all(cache::Category::FetchUrl).unwrap(); let png_size_1 = ImageSize { @@ -188,4 +187,15 @@ mod unit_test { assert_eq!(gif_size, get_image_size_from_url(gif_url).await.unwrap()); assert!(get_image_size_from_url(mp3_url).await.is_err()); } + + #[tokio::test] + async fn too_many_attempts() { + let url = "https://firefish.dev/firefish/firefish/-/raw/5891a90f71a8b9d5ea99c683ade7e485c685d642/packages/backend/assets/splash.png"; + + // delete caches in case you run this test multiple times + cache::delete_one(cache::Category::FetchUrl, url).unwrap(); + + assert!(get_image_size_from_url(url).await.is_ok()); + assert!(get_image_size_from_url(url).await.is_err()); + } } diff --git a/packages/backend-rs/src/misc/latest_version.rs b/packages/backend-rs/src/misc/latest_version.rs index 13945fcdda..2b56f31055 100644 --- a/packages/backend-rs/src/misc/latest_version.rs +++ b/packages/backend-rs/src/misc/latest_version.rs @@ -75,11 +75,17 @@ mod unit_test { // DD assert!(&version[6..8] >= "01"); assert!(&version[6..8] <= "31"); + + // -X + if version.len() > 8 { + assert!(version.chars().nth(8).unwrap() == '-'); + assert!(version[9..].chars().all(|c| c.is_ascii_digit())); + } } #[tokio::test] async fn check_version() { - #[cfg(not(feature = "ci"))] + // delete caches in case you run this test multiple times cache::delete_one(cache::Category::FetchUrl, UPSTREAM_PACKAGE_JSON_URL).unwrap(); // fetch from firefish.dev