fix test by avoiding network fetch

This commit is contained in:
Felix Ableitner 2024-03-06 15:44:31 +01:00
parent 20d454794d
commit cca2a123d0
3 changed files with 17 additions and 24 deletions

View file

@ -92,6 +92,7 @@ impl LemmyContext {
let config = FederationConfig::builder()
.domain(context.settings().hostname.clone())
.app_data(context)
.http_fetch_limit(0)
.build()
.await
.expect("build federation config");

View file

@ -11,21 +11,21 @@
"votersCount": "toot:votersCount"
}
],
"id": "https://dice.camp/users/thekernelinyellow/statuses/110830743680706519",
"id": "https://masto.qa.urbanwildlife.biz/users/mastodon/statuses/110830743680706519",
"type": "Note",
"summary": null,
"inReplyTo": null,
"published": "2023-08-04T09:55:39Z",
"url": "https://dice.camp/@thekernelinyellow/110830743680706519",
"attributedTo": "https://dice.camp/users/thekernelinyellow",
"url": "https://masto.qa.urbanwildlife.biz/110830743680706519",
"attributedTo": "https://masto.qa.urbanwildlife.biz/users/mastodon",
"to": ["https://www.w3.org/ns/activitystreams#Public"],
"cc": [
"https://dice.camp/users/thekernelinyellow/followers",
"https://masto.qa.urbanwildlife.biz/users/mastodon/followers",
"https://enterprise.lemmy.ml/c/tenforward",
"https://enterprise.lemmy.ml/c/tenforward/followers"
],
"sensitive": false,
"atomUri": "https://dice.camp/users/thekernelinyellow/statuses/110830743680706519",
"atomUri": "https://masto.qa.urbanwildlife.biz/statuses/110830743680706519",
"inReplyToAtomUri": null,
"conversation": "tag:dice.camp,2023-08-04:objectId=29969291:objectType=Conversation",
"content": "<p><span class=\"h-card\" translate=\"no\"><a href=\"https://enterprise.lemmy.ml/c/tenforward\" class=\"u-url mention\">@<span>tenforward</span></a></span> Variable never resetting at refresh</p><p>Hi! I&#39;m using a variable to count elements in my generator but every time I generate a new character, the counter&#39;s value carries on from the previous one. Is there a function to reset it (I set it to 0 at the beginning of the file)</p>",
@ -41,12 +41,12 @@
}
],
"replies": {
"id": "https://dice.camp/users/thekernelinyellow/statuses/110830743680706519/replies",
"id": "https://masto.qa.urbanwildlife.biz/users/mastodon/statuses/110830743680706519/replies",
"type": "Collection",
"first": {
"type": "CollectionPage",
"next": "https://dice.camp/users/thekernelinyellow/statuses/110830743680706519/replies?only_other_accounts=true&page=true",
"partOf": "https://dice.camp/users/thekernelinyellow/statuses/110830743680706519/replies",
"next": "https://masto.qa.urbanwildlife.biz/users/mastodon/statuses/110830743680706519/replies?only_other_accounts=true&page=true",
"partOf": "https://masto.qa.urbanwildlife.biz/users/mastodon/statuses/110830743680706519/replies",
"items": []
}
}

View file

@ -293,8 +293,7 @@ mod tests {
use super::*;
use crate::{
objects::{
community::{tests::parse_lemmy_community, ApubCommunity},
instance::ApubSite,
community::tests::parse_lemmy_community,
person::{tests::parse_lemmy_person, ApubPerson},
},
protocol::tests::file_to_json_object,
@ -324,7 +323,10 @@ mod tests {
assert!(!post.featured_community);
assert_eq!(context.request_count(), 0);
cleanup(&context, person, site, community, post).await?;
Post::delete(&mut context.pool(), post.id).await?;
Person::delete(&mut context.pool(), person.id).await?;
Community::delete(&mut context.pool(), community.id).await?;
Site::delete(&mut context.pool(), site.id).await?;
Ok(())
}
@ -332,29 +334,19 @@ mod tests {
#[serial]
async fn test_convert_mastodon_post_title() -> LemmyResult<()> {
let context = LemmyContext::init_test_context().await;
let (person, site) = parse_lemmy_person(&context).await?;
let community = parse_lemmy_community(&context).await?;
let json = file_to_json_object("assets/mastodon/objects/person.json")?;
let person = ApubPerson::from_json(json, &context).await?;
let json = file_to_json_object("assets/mastodon/objects/page.json")?;
let post = ApubPost::from_json(json, &context).await?;
assert_eq!(post.name, "Variable never resetting at refresh");
cleanup(&context, person, site, community, post).await?;
Ok(())
}
async fn cleanup(
context: &Data<LemmyContext>,
person: ApubPerson,
site: ApubSite,
community: ApubCommunity,
post: ApubPost,
) -> LemmyResult<()> {
Post::delete(&mut context.pool(), post.id).await?;
Person::delete(&mut context.pool(), person.id).await?;
Community::delete(&mut context.pool(), community.id).await?;
Site::delete(&mut context.pool(), site.id).await?;
Ok(())
}
}