Skip to content

Commit 884fc33

Browse files
committed
refactor: Replace load_config with AppConfig::init in tests for consistency
Signed-off-by: cc <i@cclvi.cc>
1 parent f0b4986 commit 884fc33

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

src/api/history.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,11 @@ pub async fn get_private_history(
6464
#[cfg(test)]
6565
mod tests {
6666
use super::*;
67-
use crate::config::load_config;
6867

6968
#[tokio::test]
7069
#[ignore = "Requires an API server in internal network"]
7170
async fn test_get_group_history() {
72-
let config = load_config().expect("Failed to load config");
71+
let config = AppConfig::init().expect("Failed to load config");
7372
println!("Loaded config");
7473

7574
match get_group_history(&config, 738943282, 20, true).await {
@@ -85,7 +84,7 @@ mod tests {
8584
#[tokio::test]
8685
#[ignore = "Requires an API server in internal network"]
8786
async fn test_get_private_history() {
88-
let config = load_config().expect("Failed to load config");
87+
let config = AppConfig::init().expect("Failed to load config");
8988
println!("Loaded config");
9089

9190
match get_private_history(&config, 46595749, 20, true).await {

src/api/poke.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,36 +42,35 @@ pub async fn group_poke(config: &AppConfig, group_id: u64, to: u64) {
4242
#[cfg(test)]
4343
mod tests {
4444
use super::*;
45-
use crate::config::load_config;
4645

4746
#[tokio::test]
4847
#[ignore = "Requires an API server in internal network"]
4948
async fn test_private_poke() {
50-
let config = load_config().expect("Failed to load config");
49+
let config = AppConfig::init().expect("Failed to load config");
5150
println!("Loaded config");
5251
private_poke(&config, 46595749, false).await;
5352
}
5453

5554
#[tokio::test]
5655
#[ignore = "Requires an API server in internal network"]
5756
async fn test_private_self_poke() {
58-
let config = load_config().expect("Failed to load config");
57+
let config = AppConfig::init().expect("Failed to load config");
5958
println!("Loaded config");
6059
private_poke(&config, 46595749, true).await;
6160
}
6261

6362
#[tokio::test]
6463
#[ignore = "Requires an API server in internal network"]
6564
async fn test_group_poke() {
66-
let config = load_config().expect("Failed to load config");
65+
let config = AppConfig::init().expect("Failed to load config");
6766
println!("Loaded config");
6867
group_poke(&config, 738943282, 46595749).await;
6968
}
7069

7170
#[tokio::test]
7271
#[ignore = "Requires an API server in internal network"]
7372
async fn test_group_self_poke() {
74-
let config = load_config().expect("Failed to load config");
73+
let config = AppConfig::init().expect("Failed to load config");
7574
println!("Loaded config");
7675
group_poke(&config, 738943282, config.botcat_capoo.id).await;
7776
}

src/api/send_message.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ pub async fn send_private_message(config: &AppConfig, to: u64, message: Message)
3939
#[cfg(test)]
4040
mod tests {
4141
use super::*;
42-
use crate::config::load_config;
42+
4343
use crate::model::message::segment::MessageSegment;
4444

4545
#[tokio::test]
4646
#[ignore = "Requires an API server in internal network"]
4747
async fn test_send_group_message() {
48-
let config = load_config().expect("Failed to load config");
48+
let config = AppConfig::init().expect("Failed to load config");
4949
println!("Loaded config");
5050
let message = vec![
5151
MessageSegment::At {
@@ -61,7 +61,7 @@ mod tests {
6161
#[tokio::test]
6262
#[ignore = "Requires an API server in internal network"]
6363
async fn test_send_private_message() {
64-
let config = load_config().expect("Failed to load config");
64+
let config = AppConfig::init().expect("Failed to load config");
6565
println!("Loaded config");
6666
let message = vec![MessageSegment::Text {
6767
text: "Hello, user!".to_string(),

src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ mod tests {
132132

133133
#[test]
134134
#[ignore = "Requires secret files which are not included in the repository"]
135-
fn test_load_config() {
135+
fn test_config_initialization() {
136136
let config = AppConfig::init();
137137
assert!(config.is_ok());
138138
}

0 commit comments

Comments
 (0)