add snapshot testing with insta
This commit is contained in:
parent
25a9398b85
commit
15e854b341
13 changed files with 6710 additions and 42 deletions
|
|
@ -10,7 +10,7 @@ use log::warn;
|
|||
use once_cell::sync::Lazy;
|
||||
use rand::Rng;
|
||||
use reqwest::{header, Client, ClientBuilder, Method, Request, RequestBuilder, Response};
|
||||
use serde::Serialize;
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
use crate::{
|
||||
cache::{Cache, DesktopClientData},
|
||||
|
|
@ -18,7 +18,8 @@ use crate::{
|
|||
util,
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum ClientType {
|
||||
Desktop,
|
||||
DesktopMusic,
|
||||
|
|
@ -168,6 +169,7 @@ pub trait YTClient {
|
|||
async fn get_context(&self, localized: bool) -> ContextYT;
|
||||
async fn request_builder(&self, method: Method, url: &str) -> RequestBuilder;
|
||||
fn http_client(&self) -> Client;
|
||||
fn get_type(&self) -> ClientType;
|
||||
}
|
||||
|
||||
async fn exec_request(http: Client, request: Request) -> Result<Response> {
|
||||
|
|
@ -231,6 +233,10 @@ impl YTClient for DesktopClient {
|
|||
fn http_client(&self) -> Client {
|
||||
self.http.clone()
|
||||
}
|
||||
|
||||
fn get_type(&self)-> ClientType {
|
||||
ClientType::Desktop
|
||||
}
|
||||
}
|
||||
|
||||
impl DesktopClient {
|
||||
|
|
@ -363,6 +369,10 @@ impl YTClient for AndroidClient {
|
|||
fn http_client(&self) -> Client {
|
||||
self.http.clone()
|
||||
}
|
||||
|
||||
fn get_type(&self)-> ClientType {
|
||||
ClientType::Android
|
||||
}
|
||||
}
|
||||
|
||||
impl AndroidClient {
|
||||
|
|
@ -430,6 +440,10 @@ impl YTClient for IosClient {
|
|||
fn http_client(&self) -> Client {
|
||||
self.http.clone()
|
||||
}
|
||||
|
||||
fn get_type(&self)-> ClientType {
|
||||
ClientType::Ios
|
||||
}
|
||||
}
|
||||
|
||||
impl IosClient {
|
||||
|
|
@ -500,6 +514,10 @@ impl YTClient for TvHtml5EmbedClient {
|
|||
fn http_client(&self) -> Client {
|
||||
self.http.clone()
|
||||
}
|
||||
|
||||
fn get_type(&self)-> ClientType {
|
||||
ClientType::TvHtml5Embed
|
||||
}
|
||||
}
|
||||
|
||||
impl TvHtml5EmbedClient {
|
||||
|
|
|
|||
Reference in a new issue