-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(podcasts): filter out keywords (#1199)
- Loading branch information
1 parent
eabd062
commit acd9fe8
Showing
6 changed files
with
142 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod device_test_builder; | ||
pub mod notification_test_builder; | ||
pub mod user_test_builder; | ||
pub mod podcast_test_builder; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#[cfg(test)] | ||
pub mod tests { | ||
use derive_builder::Builder; | ||
use fake::Fake; | ||
use fake::Faker; | ||
use fake::faker::lorem::de_de::Word; | ||
use crate::models::podcasts::Podcast; | ||
|
||
#[derive(Default, Builder, Debug)] | ||
#[builder(setter(into), default)] | ||
pub struct PodcastTestData { | ||
pub id: i32, | ||
pub name: String, | ||
pub directory_id: String, | ||
pub rssfeed: String, | ||
pub image_url: String, | ||
pub summary: Option<String>, | ||
pub language: Option<String>, | ||
pub explicit: Option<String>, | ||
pub keywords: Option<String>, | ||
pub last_build_date: Option<String>, | ||
pub author: Option<String>, | ||
pub active: bool, | ||
pub original_image_url: String, | ||
pub directory_name: String, | ||
pub download_location: Option<String> | ||
} | ||
|
||
impl PodcastTestData { | ||
pub fn new() -> PodcastTestData { | ||
let num_of_keywords: i32 = Faker.fake(); | ||
let keywords: String = (0..num_of_keywords).map(|_| Word().fake()).collect::<Vec<String>>().join(","); | ||
|
||
PodcastTestData { | ||
id: Faker.fake(), | ||
name: Faker.fake(), | ||
directory_id: Faker.fake(), | ||
rssfeed: Faker.fake(), | ||
image_url: Faker.fake(), | ||
summary: Some(Faker.fake()), | ||
language: Some(Faker.fake()), | ||
explicit: Some(Faker.fake()), | ||
keywords: Some(keywords), | ||
last_build_date: Faker.fake(), | ||
author: Faker.fake(), | ||
active: Faker.fake(), | ||
original_image_url: Faker.fake(), | ||
directory_name: Faker.fake(), | ||
download_location: None, | ||
} | ||
} | ||
|
||
pub fn build(self) -> Podcast { | ||
Podcast { | ||
id: self.id, | ||
name: self.name, | ||
directory_id: self.directory_id, | ||
rssfeed: self.rssfeed, | ||
image_url: self.image_url, | ||
summary: self.summary, | ||
author: self.author, | ||
active: self.active, | ||
original_image_url: self.original_image_url, | ||
directory_name: self.directory_name, | ||
download_location: self.download_location, | ||
explicit: self.explicit, | ||
last_build_date: self.last_build_date, | ||
keywords: self.keywords, | ||
language: self.language, | ||
} | ||
} | ||
} | ||
|
||
impl From<PodcastTestData> for Podcast { | ||
fn from(value: PodcastTestData) -> Self { | ||
Podcast { | ||
id: value.id, | ||
name: value.name, | ||
directory_id: value.directory_id, | ||
keywords: value.keywords, | ||
language: value.language, | ||
active: value.active, | ||
original_image_url: value.original_image_url, | ||
directory_name: value.directory_name, | ||
download_location: value.download_location, | ||
explicit: value.explicit, | ||
last_build_date: value.last_build_date, | ||
author: value.author, | ||
summary: value.summary, | ||
image_url: value.image_url, | ||
rssfeed: value.rssfeed, | ||
} | ||
} | ||
} | ||
|
||
} |