mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-02 17:21:22 +00:00
fix test by avoiding network fetch
This commit is contained in:
parent
20d454794d
commit
cca2a123d0
3 changed files with 17 additions and 24 deletions
|
@ -92,6 +92,7 @@ impl LemmyContext {
|
||||||
let config = FederationConfig::builder()
|
let config = FederationConfig::builder()
|
||||||
.domain(context.settings().hostname.clone())
|
.domain(context.settings().hostname.clone())
|
||||||
.app_data(context)
|
.app_data(context)
|
||||||
|
.http_fetch_limit(0)
|
||||||
.build()
|
.build()
|
||||||
.await
|
.await
|
||||||
.expect("build federation config");
|
.expect("build federation config");
|
||||||
|
|
|
@ -11,21 +11,21 @@
|
||||||
"votersCount": "toot:votersCount"
|
"votersCount": "toot:votersCount"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"id": "https://dice.camp/users/thekernelinyellow/statuses/110830743680706519",
|
"id": "https://masto.qa.urbanwildlife.biz/users/mastodon/statuses/110830743680706519",
|
||||||
"type": "Note",
|
"type": "Note",
|
||||||
"summary": null,
|
"summary": null,
|
||||||
"inReplyTo": null,
|
"inReplyTo": null,
|
||||||
"published": "2023-08-04T09:55:39Z",
|
"published": "2023-08-04T09:55:39Z",
|
||||||
"url": "https://dice.camp/@thekernelinyellow/110830743680706519",
|
"url": "https://masto.qa.urbanwildlife.biz/110830743680706519",
|
||||||
"attributedTo": "https://dice.camp/users/thekernelinyellow",
|
"attributedTo": "https://masto.qa.urbanwildlife.biz/users/mastodon",
|
||||||
"to": ["https://www.w3.org/ns/activitystreams#Public"],
|
"to": ["https://www.w3.org/ns/activitystreams#Public"],
|
||||||
"cc": [
|
"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",
|
||||||
"https://enterprise.lemmy.ml/c/tenforward/followers"
|
"https://enterprise.lemmy.ml/c/tenforward/followers"
|
||||||
],
|
],
|
||||||
"sensitive": false,
|
"sensitive": false,
|
||||||
"atomUri": "https://dice.camp/users/thekernelinyellow/statuses/110830743680706519",
|
"atomUri": "https://masto.qa.urbanwildlife.biz/statuses/110830743680706519",
|
||||||
"inReplyToAtomUri": null,
|
"inReplyToAtomUri": null,
|
||||||
"conversation": "tag:dice.camp,2023-08-04:objectId=29969291:objectType=Conversation",
|
"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'm using a variable to count elements in my generator but every time I generate a new character, the counter'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>",
|
"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'm using a variable to count elements in my generator but every time I generate a new character, the counter'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": {
|
"replies": {
|
||||||
"id": "https://dice.camp/users/thekernelinyellow/statuses/110830743680706519/replies",
|
"id": "https://masto.qa.urbanwildlife.biz/users/mastodon/statuses/110830743680706519/replies",
|
||||||
"type": "Collection",
|
"type": "Collection",
|
||||||
"first": {
|
"first": {
|
||||||
"type": "CollectionPage",
|
"type": "CollectionPage",
|
||||||
"next": "https://dice.camp/users/thekernelinyellow/statuses/110830743680706519/replies?only_other_accounts=true&page=true",
|
"next": "https://masto.qa.urbanwildlife.biz/users/mastodon/statuses/110830743680706519/replies?only_other_accounts=true&page=true",
|
||||||
"partOf": "https://dice.camp/users/thekernelinyellow/statuses/110830743680706519/replies",
|
"partOf": "https://masto.qa.urbanwildlife.biz/users/mastodon/statuses/110830743680706519/replies",
|
||||||
"items": []
|
"items": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -293,8 +293,7 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
objects::{
|
objects::{
|
||||||
community::{tests::parse_lemmy_community, ApubCommunity},
|
community::tests::parse_lemmy_community,
|
||||||
instance::ApubSite,
|
|
||||||
person::{tests::parse_lemmy_person, ApubPerson},
|
person::{tests::parse_lemmy_person, ApubPerson},
|
||||||
},
|
},
|
||||||
protocol::tests::file_to_json_object,
|
protocol::tests::file_to_json_object,
|
||||||
|
@ -324,7 +323,10 @@ mod tests {
|
||||||
assert!(!post.featured_community);
|
assert!(!post.featured_community);
|
||||||
assert_eq!(context.request_count(), 0);
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,29 +334,19 @@ mod tests {
|
||||||
#[serial]
|
#[serial]
|
||||||
async fn test_convert_mastodon_post_title() -> LemmyResult<()> {
|
async fn test_convert_mastodon_post_title() -> LemmyResult<()> {
|
||||||
let context = LemmyContext::init_test_context().await;
|
let context = LemmyContext::init_test_context().await;
|
||||||
let (person, site) = parse_lemmy_person(&context).await?;
|
|
||||||
let community = parse_lemmy_community(&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 json = file_to_json_object("assets/mastodon/objects/page.json")?;
|
||||||
let post = ApubPost::from_json(json, &context).await?;
|
let post = ApubPost::from_json(json, &context).await?;
|
||||||
|
|
||||||
assert_eq!(post.name, "Variable never resetting at refresh");
|
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?;
|
Post::delete(&mut context.pool(), post.id).await?;
|
||||||
Person::delete(&mut context.pool(), person.id).await?;
|
Person::delete(&mut context.pool(), person.id).await?;
|
||||||
Community::delete(&mut context.pool(), community.id).await?;
|
Community::delete(&mut context.pool(), community.id).await?;
|
||||||
Site::delete(&mut context.pool(), site.id).await?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue