refactor: group use at the top of the test modules

This commit is contained in:
link2xt
2024-04-23 21:07:50 +00:00
parent 2108a8ba94
commit e9280b8413
3 changed files with 7 additions and 12 deletions

View File

@@ -2002,6 +2002,7 @@ mod tests {
use super::*; use super::*;
use crate::chat::{self, marknoticed_chat, send_text_msg, ChatItem}; use crate::chat::{self, marknoticed_chat, send_text_msg, ChatItem};
use crate::chatlist::Chatlist; use crate::chatlist::Chatlist;
use crate::config::Config;
use crate::reaction::send_reaction; use crate::reaction::send_reaction;
use crate::receive_imf::receive_imf; use crate::receive_imf::receive_imf;
use crate::test_utils as test; use crate::test_utils as test;
@@ -2025,8 +2026,6 @@ mod tests {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_prepare_message_and_send() { async fn test_prepare_message_and_send() {
use crate::config::Config;
let d = test::TestContext::new().await; let d = test::TestContext::new().await;
let ctx = &d.ctx; let ctx = &d.ctx;
@@ -2165,8 +2164,6 @@ mod tests {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_quote() { async fn test_quote() {
use crate::config::Config;
let d = test::TestContext::new().await; let d = test::TestContext::new().await;
let ctx = &d.ctx; let ctx = &d.ctx;

View File

@@ -683,7 +683,12 @@ pub(crate) fn buf_decompress(buf: &[u8]) -> Result<Vec<u8>> {
mod tests { mod tests {
#![allow(clippy::indexing_slicing)] #![allow(clippy::indexing_slicing)]
use chrono::NaiveDate;
use proptest::prelude::*;
use super::*; use super::*;
use crate::chatlist::Chatlist;
use crate::{chat, test_utils};
use crate::{receive_imf::receive_imf, test_utils::TestContext}; use crate::{receive_imf::receive_imf, test_utils::TestContext};
#[test] #[test]
@@ -961,12 +966,6 @@ DKIM Results: Passed=true, Works=true, Allow_Keychange=true";
assert!(extract_grpid_from_rfc724_mid(mid.as_str()).is_none()); assert!(extract_grpid_from_rfc724_mid(mid.as_str()).is_none());
} }
use chrono::NaiveDate;
use proptest::prelude::*;
use crate::chatlist::Chatlist;
use crate::{chat, test_utils};
proptest! { proptest! {
#[test] #[test]
fn test_truncate( fn test_truncate(

View File

@@ -862,6 +862,7 @@ impl Message {
mod tests { mod tests {
use std::time::Duration; use std::time::Duration;
use regex::Regex;
use serde_json::json; use serde_json::json;
use super::*; use super::*;
@@ -1711,8 +1712,6 @@ mod tests {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_render_webxdc_status_update_object_range() -> Result<()> { async fn test_render_webxdc_status_update_object_range() -> Result<()> {
use regex::Regex;
let t = TestContext::new_alice().await; let t = TestContext::new_alice().await;
let chat_id = create_group_chat(&t, ProtectionStatus::Unprotected, "a chat").await?; let chat_id = create_group_chat(&t, ProtectionStatus::Unprotected, "a chat").await?;
let instance = send_webxdc_instance(&t, chat_id).await?; let instance = send_webxdc_instance(&t, chat_id).await?;