Favicon: Fix tests

This commit is contained in:
Bilal Elmoussaoui 2022-04-22 00:55:43 +02:00
parent 4f979d246a
commit 56e196346f

View file

@ -1,6 +1,6 @@
use tokio::{io::AsyncWriteExt, sync::Mutex};
use image::io::Reader as ImageReader; use image::io::Reader as ImageReader;
use std::{fmt, io::Cursor, path::PathBuf}; use std::{fmt, io::Cursor, path::PathBuf};
use tokio::{io::AsyncWriteExt, sync::Mutex};
use url::Url; use url::Url;
use crate::{Error, Format, Metadata, CLIENT}; use crate::{Error, Format, Metadata, CLIENT};
@ -13,9 +13,9 @@ pub struct Favicon {
} }
impl Favicon { impl Favicon {
pub(crate) fn for_url(url: Url, metadata: Metadata) -> Self { pub(crate) fn for_url<U: reqwest::IntoUrl>(url: U, metadata: Metadata) -> Self {
Self { Self {
url: Some(url), url: Some(url.into_url().expect("Favicon expects a valid url")),
metadata, metadata,
data: Default::default(), data: Default::default(),
is_url: true, 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
}
}