mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-07 19:22:14 +09:00
test: remove infrastructure-dependent integration suites (#1573)
This commit is contained in:
@@ -1743,65 +1743,4 @@ mod tests {
|
||||
"**[\u{1F4AC}](https://x.com/intent/tweet?in_reply_to=1299530165463199747) 135\\.1K\u{2002}[\u{1F501}](https://x.com/intent/retweet?tweet_id=1299530165463199747) 1\\.76M\u{2002}[\u{2764}\u{FE0F}](https://x.com/intent/like?tweet_id=1299530165463199747) 6\\.59M\u{2002}**"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "hits the live FxTwitter API"]
|
||||
async fn live_example_pipeline_matches_reference() {
|
||||
let client = reqwest::Client::builder()
|
||||
.user_agent("Mozilla/5.0 (compatible; Fluxerbot/1.0; +https://fluxer.app)")
|
||||
.redirect(reqwest::redirect::Policy::none())
|
||||
.build()
|
||||
.unwrap();
|
||||
let res = http_fetch::fetch_url(
|
||||
&client,
|
||||
&format!("{FXTWITTER_API_BASE}/AdolphsonFalkk/status/2050662857763688642"),
|
||||
API_MAX_BYTES,
|
||||
API_TIMEOUT,
|
||||
)
|
||||
.await
|
||||
.expect("fetch fxtwitter api");
|
||||
assert_eq!(res.status, 200);
|
||||
let tweet = serde_json::from_slice::<FxResponse>(&res.bytes)
|
||||
.expect("parse api json")
|
||||
.tweet
|
||||
.expect("tweet present");
|
||||
|
||||
assert_eq!(
|
||||
tweet.author.as_ref().and_then(|a| a.screen_name.as_deref()),
|
||||
Some("AdolphsonFalkk")
|
||||
);
|
||||
assert_eq!(
|
||||
tweet
|
||||
.created_timestamp
|
||||
.and_then(format_timestamp)
|
||||
.as_deref(),
|
||||
Some("2026-05-02T19:44:59Z")
|
||||
);
|
||||
|
||||
let media = select_media_source(&tweet).expect("media source");
|
||||
assert!(
|
||||
media
|
||||
.photos
|
||||
.as_ref()
|
||||
.is_some_and(|photos| !photos.is_empty())
|
||||
);
|
||||
|
||||
let description = build_description(&tweet);
|
||||
assert!(
|
||||
description.starts_with(
|
||||
"No that's fine I just imagined it would be a bit bigger\n\n> **[Quoting](https://x.com/ScandinavianAE/status/2050646038420045877) Scandinavian Aesthetics \\([@ScandinavianAE](https://x.com/ScandinavianAE)\\)**\n> \u{FE00}\n> Sweden \u{1F1F8}\u{1F1EA}\n\n**[\u{1F4AC}](https://x.com/intent/tweet?in_reply_to=2050662857763688642) "
|
||||
),
|
||||
"description was: {description:?}"
|
||||
);
|
||||
assert!(
|
||||
description.contains(
|
||||
"[\u{1F501}](https://x.com/intent/retweet?tweet_id=2050662857763688642) "
|
||||
)
|
||||
);
|
||||
assert!(description.contains(
|
||||
"[\u{2764}\u{FE0F}](https://x.com/intent/like?tweet_id=2050662857763688642) "
|
||||
));
|
||||
assert!(description.contains("\u{1F441}\u{FE0F} "));
|
||||
assert!(description.ends_with("\u{2002}**"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -463,66 +463,6 @@ mod tests {
|
||||
assert!(media.thumbnail.is_none());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "hits the live KLIPY API and local media proxy"]
|
||||
async fn live_klipy_embed_resolves_real_media() {
|
||||
let api_key = std::env::var("FLUXER_KLIPY_API_KEY").expect("FLUXER_KLIPY_API_KEY set");
|
||||
let media_proxy_endpoint =
|
||||
std::env::var("FLUXER_MEDIA_PROXY_ENDPOINT").expect("FLUXER_MEDIA_PROXY_ENDPOINT set");
|
||||
let media_proxy_secret = std::env::var("FLUXER_MEDIA_PROXY_SECRET_KEY")
|
||||
.expect("FLUXER_MEDIA_PROXY_SECRET_KEY set");
|
||||
let media_proxy_public_endpoint = std::env::var("FLUXER_MEDIA_PROXY_PUBLIC_ENDPOINT").ok();
|
||||
let raw_url = std::env::var("FLUXER_KLIPY_LIVE_URL")
|
||||
.unwrap_or_else(|_| "https://klipy.com/gifs/goatplaybanjo-chat-4".to_owned());
|
||||
|
||||
let resolver = KlipyResolver;
|
||||
let original_url = Url::parse(&raw_url).expect("valid live KLIPY URL");
|
||||
let url = resolver
|
||||
.transform_url(&original_url)
|
||||
.unwrap_or_else(|| original_url.clone());
|
||||
let media_proxy = crate::media_proxy::MediaProxyClient::new_with_public_endpoint(
|
||||
&media_proxy_endpoint,
|
||||
&media_proxy_secret,
|
||||
media_proxy_public_endpoint.as_deref(),
|
||||
reqwest::Client::new(),
|
||||
);
|
||||
let ctx = ResolveContext {
|
||||
url,
|
||||
original_url: original_url.clone(),
|
||||
http_client: reqwest::Client::new(),
|
||||
nsfw_mode: crate::types::NsfwMode::Allow,
|
||||
media_proxy: &media_proxy,
|
||||
static_cdn_endpoint: "",
|
||||
youtube_api_key: None,
|
||||
klipy_api_key: Some(api_key),
|
||||
};
|
||||
|
||||
let result = resolver.resolve(&ctx).await.expect("resolve KLIPY embed");
|
||||
assert_eq!(result.embeds.len(), 1);
|
||||
let embed = &result.embeds[0];
|
||||
assert_eq!(embed.embed_type, "gifv");
|
||||
assert_eq!(embed.url.as_deref(), Some(original_url.as_str()));
|
||||
assert_eq!(
|
||||
embed
|
||||
.provider
|
||||
.as_ref()
|
||||
.and_then(|provider| provider.name.as_deref()),
|
||||
Some("KLIPY")
|
||||
);
|
||||
let video = embed.video.as_ref().expect("video media resolved");
|
||||
assert!(
|
||||
video
|
||||
.url
|
||||
.as_deref()
|
||||
.is_some_and(|url| url.starts_with("https://"))
|
||||
);
|
||||
assert!(video.width.is_some_and(|width| width > 0));
|
||||
assert!(video.height.is_some_and(|height| height > 0));
|
||||
assert!(video.content_type.as_deref().is_some_and(|content_type| {
|
||||
content_type.starts_with("video/") || content_type == "image/gif"
|
||||
}));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resolve_relative_url_rejects_non_http() {
|
||||
let base = Url::parse("https://klipy.com/gifs/test").unwrap();
|
||||
|
||||
Reference in New Issue
Block a user