From 56e196346fb070546239eb7b1ceede8f83bb8f9a Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Fri, 22 Apr 2022 00:55:43 +0200 Subject: [PATCH] Favicon: Fix tests --- favicon-scrapper/src/favicon.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/favicon-scrapper/src/favicon.rs b/favicon-scrapper/src/favicon.rs index fefaeca..3b68a52 100644 --- a/favicon-scrapper/src/favicon.rs +++ b/favicon-scrapper/src/favicon.rs @@ -1,6 +1,6 @@ -use tokio::{io::AsyncWriteExt, sync::Mutex}; use image::io::Reader as ImageReader; use std::{fmt, io::Cursor, path::PathBuf}; +use tokio::{io::AsyncWriteExt, sync::Mutex}; use url::Url; use crate::{Error, Format, Metadata, CLIENT}; @@ -13,9 +13,9 @@ pub struct Favicon { } impl Favicon { - pub(crate) fn for_url(url: Url, metadata: Metadata) -> Self { + pub(crate) fn for_url(url: U, metadata: Metadata) -> Self { Self { - url: Some(url), + url: Some(url.into_url().expect("Favicon expects a valid url")), metadata, data: Default::default(), is_url: true, @@ -141,3 +141,9 @@ impl fmt::Debug for Favicon { } } } + +impl PartialEq for Favicon { + fn eq(&self, other: &Self) -> bool { + self.is_url == other.is_url && self.metadata == other.metadata && self.url == other.url + } +}