Fix episodes being optional

Signed-off-by: trivernis <trivernis@protonmail.com>
main
trivernis 2 years ago
parent 34d5d35953
commit a15743bd65
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -1,6 +1,6 @@
[package]
name = "animethemes-rs"
version = "0.4.3"
version = "0.4.4"
authors = ["trivernis <trivernis@protonmail.com>"]
edition = "2021"
readme = "README.md"

@ -10,6 +10,11 @@ macro_rules! theme_include {
}
impl $name {
pub fn all() -> Self {
Self {
$($field: true),+
}
}
$(pub fn $field(mut self) -> Self {
self.$field = true;
@ -149,7 +154,7 @@ theme_include!(
#[derive(Clone, Copy, Default, Debug)]
pub struct SearchIncludes {
pub anime: AnimeInclude,
pub animethemes: ThemeInclude,
pub themes: ThemeInclude,
pub artists: ArtistInclude,
pub series: SeriesInclude,
pub songs: SongInclude,
@ -157,10 +162,21 @@ pub struct SearchIncludes {
}
impl SearchIncludes {
pub fn all() -> Self {
Self {
anime: AnimeInclude::all(),
themes: ThemeInclude::all(),
artists: ArtistInclude::all(),
series: SeriesInclude::all(),
songs: SongInclude::all(),
videos: VideoInclude::all(),
}
}
pub fn indo_includes(self) -> Vec<(String, String)> {
let mut includes = Vec::new();
let anime_includes = self.anime.includes();
let animetheme_includes = self.animethemes.includes();
let animetheme_includes = self.themes.includes();
let artist_includes = self.artists.includes();
let series_includes = self.series.includes();
let song_includes = self.songs.includes();

@ -91,7 +91,7 @@ pub struct ThemeEntry {
pub meta: EntryMetadata,
#[serde(deserialize_with = "crate::utils::empty_string_as_none")]
pub version: Option<u32>,
pub episodes: String,
pub episodes: Option<String>,
pub nsfw: bool,
pub spoiler: bool,
pub notes: Option<String>,

@ -1,6 +1,22 @@
use crate::client::AnimeThemesClient;
use crate::includes::*;
const TEST_QUERIES: &[&str] = &[
"vivy",
"papiri koumei",
"re:zero",
"demon slayer",
"spirited away",
"classroom of the elite",
"tower of god",
"made in abyss",
"wonder egg priority",
"spider",
"bookworm",
"slime",
"kaguya",
];
#[tokio::test]
async fn it_searches() {
let client = AnimeThemesClient::default();
@ -26,6 +42,25 @@ async fn it_searches() {
assert!(result.videos.is_some());
}
#[tokio::test]
async fn all_models_are_correct() {
let client = AnimeThemesClient::default();
for query in TEST_QUERIES {
println!("testing query '{query}'");
let result = client
.search(query, &[], SearchIncludes::all())
.await
.unwrap();
assert!(result.artists.is_some());
assert!(result.songs.is_some());
assert!(result.anime.is_some());
assert!(result.series.is_some());
assert!(result.themes.is_some());
assert!(result.videos.is_some());
}
}
#[tokio::test]
async fn it_returns_anime_by_slug() {
let client = AnimeThemesClient::default();

Loading…
Cancel
Save