mirror of
https://github.com/TheFunny/TelegramTwitterMediaBot.git
synced 2026-10-05 01:12:06 +00:00
test: share the photo payload fixture, drop two test-only aliases
The one-photo MediaItemPayload literal was written out at six sites across the urls and send test modules; ctx::test_support::photo_item holds it once. permanent_error now delegates to api_error (it stays a fn pointer because that is what MockSender::scripted takes), misskey's x_media_site_id wrapper is gone in favour of the function it renamed, and PixivAPI is no longer re-exported -- nothing outside pixiv/api.rs names it.
This commit is contained in:
@@ -50,6 +50,7 @@ pub static CONTEXT: LazyLock<AppContext<'static>> =
|
||||
pub(crate) mod test_support {
|
||||
use super::*;
|
||||
use crate::link_cache::{CachedMedia, CachedMediaKind, CachedPost};
|
||||
use crate::send::MediaItemPayload;
|
||||
use crate::state::EditMessage;
|
||||
use std::sync::Arc;
|
||||
use teloxide::{ApiError, RequestError};
|
||||
@@ -64,6 +65,18 @@ pub(crate) mod test_support {
|
||||
RequestError::Api(ApiError::Unknown(message.to_string()))
|
||||
}
|
||||
|
||||
/// One photo payload item: `media` in the two flags the tests vary (no
|
||||
/// smaller variant, since that is the field most tests leave alone —
|
||||
/// `send`'s own tests build that case directly).
|
||||
pub(crate) fn photo_item(media: &str, has_spoiler: bool, file_id: bool) -> MediaItemPayload {
|
||||
MediaItemPayload::Photo {
|
||||
media: media.to_string(),
|
||||
has_spoiler,
|
||||
fallback_url: None,
|
||||
file_id,
|
||||
}
|
||||
}
|
||||
|
||||
/// The cached post every test that touches the link cache starts from: one
|
||||
/// photo with a Telegram file id at the canonical URL (key `twitter:1`).
|
||||
/// Tests that need another field mutate the returned value.
|
||||
|
||||
Reference in New Issue
Block a user