test (backend-rs): add tests
This commit is contained in:
parent
38c0de39b9
commit
4992999bb7
2 changed files with 19 additions and 3 deletions
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue