Merge branch 'fmt' into 'main'
Fix formatting See merge request kernald/reddit-magnet!1
This commit is contained in:
commit
3480dbe6eb
2 changed files with 21 additions and 19 deletions
|
|
@ -27,28 +27,27 @@ mod tests {
|
|||
#[test]
|
||||
fn test_empty_text() {
|
||||
let text = "";
|
||||
|
||||
|
||||
let links = extract_magnet_links(text);
|
||||
|
||||
|
||||
assert!(links.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_no_magnet_links() {
|
||||
let text = "This is a text without any magnet links";
|
||||
|
||||
|
||||
let links = extract_magnet_links(text);
|
||||
|
||||
|
||||
assert!(links.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_single_magnet_link() {
|
||||
|
||||
let text = "Here is a magnet link: magnet:?xt=urn:btih:example";
|
||||
|
||||
|
||||
let links = extract_magnet_links(text);
|
||||
|
||||
|
||||
assert_eq!(links.len(), 1);
|
||||
assert_eq!(links[0], "magnet:?xt=urn:btih:example");
|
||||
}
|
||||
|
|
@ -56,9 +55,9 @@ mod tests {
|
|||
#[test]
|
||||
fn test_multiple_magnet_links() {
|
||||
let text = "First link: magnet:?xt=urn:btih:example1 and second link: magnet:?xt=urn:btih:example2";
|
||||
|
||||
|
||||
let links = extract_magnet_links(text);
|
||||
|
||||
|
||||
assert_eq!(links.len(), 2);
|
||||
assert_eq!(links[0], "magnet:?xt=urn:btih:example1");
|
||||
assert_eq!(links[1], "magnet:?xt=urn:btih:example2");
|
||||
|
|
@ -67,9 +66,9 @@ mod tests {
|
|||
#[test]
|
||||
fn test_magnet_link_at_beginning() {
|
||||
let text = "magnet:?xt=urn:btih:example at the beginning";
|
||||
|
||||
|
||||
let links = extract_magnet_links(text);
|
||||
|
||||
|
||||
assert_eq!(links.len(), 1);
|
||||
assert_eq!(links[0], "magnet:?xt=urn:btih:example");
|
||||
}
|
||||
|
|
@ -77,9 +76,9 @@ mod tests {
|
|||
#[test]
|
||||
fn test_magnet_link_at_end() {
|
||||
let text = "Link at the end: magnet:?xt=urn:btih:example";
|
||||
|
||||
|
||||
let links = extract_magnet_links(text);
|
||||
|
||||
|
||||
assert_eq!(links.len(), 1);
|
||||
assert_eq!(links[0], "magnet:?xt=urn:btih:example");
|
||||
}
|
||||
|
|
@ -87,9 +86,9 @@ mod tests {
|
|||
#[test]
|
||||
fn test_magnet_link_without_whitespace() {
|
||||
let text = "Text containing a link:magnet:?xt=urn:btih:example";
|
||||
|
||||
|
||||
let links = extract_magnet_links(text);
|
||||
|
||||
|
||||
assert_eq!(links.len(), 1);
|
||||
assert_eq!(links[0], "magnet:?xt=urn:btih:example");
|
||||
}
|
||||
|
|
@ -97,9 +96,9 @@ mod tests {
|
|||
#[test]
|
||||
fn test_complex_magnet_link() {
|
||||
let text = "Complex link: magnet:?xt=urn:btih:a1b2c3d4e5f6g7h8i9j0&dn=example+file&tr=udp%3A%2F%2Ftracker.example.com%3A80";
|
||||
|
||||
|
||||
let links = extract_magnet_links(text);
|
||||
|
||||
|
||||
assert_eq!(links.len(), 1);
|
||||
assert_eq!(links[0], "magnet:?xt=urn:btih:a1b2c3d4e5f6g7h8i9j0&dn=example+file&tr=udp%3A%2F%2Ftracker.example.com%3A80");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ use serde::{Deserialize, Serialize};
|
|||
use std::collections::{HashMap, HashSet};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use reddit_client::RedditClient;
|
||||
use crate::magnet::{extract_magnet_links, Magnet};
|
||||
use reddit_client::RedditClient;
|
||||
|
||||
mod magnet;
|
||||
mod reddit_client;
|
||||
|
|
@ -156,7 +156,10 @@ async fn main() -> Result<()> {
|
|||
if let Some(submissions) = user_posts.get_vec(&username) {
|
||||
let mut filtered_posts = Vec::new();
|
||||
|
||||
for post in submissions.iter().filter(|s| filter_posts(&*s.title, title_filter.clone())) {
|
||||
for post in submissions
|
||||
.iter()
|
||||
.filter(|s| filter_posts(&*s.title, title_filter.clone()))
|
||||
{
|
||||
let title = &post.title;
|
||||
let body = &post.body;
|
||||
let subreddit = &post.subreddit;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue