mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-03-25 18:10:48 +08:00
chore: fix code formatting and test setup
- Format Rust code with rustfmt (misc.rs, types.rs) - Format TypeScript/React code with Prettier (4 files) - Fix ProviderList test by wrapping with QueryClientProvider
This commit is contained in:
@@ -605,8 +605,7 @@ exec bash --norc --noprofile
|
||||
script_file = script_file.display()
|
||||
);
|
||||
|
||||
std::fs::write(&script_file, &script_content)
|
||||
.map_err(|e| format!("写入启动脚本失败: {e}"))?;
|
||||
std::fs::write(&script_file, &script_content).map_err(|e| format!("写入启动脚本失败: {e}"))?;
|
||||
|
||||
// Make script executable
|
||||
std::fs::set_permissions(&script_file, std::fs::Permissions::from_mode(0o755))
|
||||
@@ -675,8 +674,7 @@ exec bash --norc --noprofile
|
||||
script_file = script_file.display()
|
||||
);
|
||||
|
||||
std::fs::write(&script_file, &script_content)
|
||||
.map_err(|e| format!("写入启动脚本失败: {e}"))?;
|
||||
std::fs::write(&script_file, &script_content).map_err(|e| format!("写入启动脚本失败: {e}"))?;
|
||||
|
||||
std::fs::set_permissions(&script_file, std::fs::Permissions::from_mode(0o755))
|
||||
.map_err(|e| format!("设置脚本权限失败: {e}"))?;
|
||||
|
||||
@@ -316,30 +316,48 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_log_config_to_level_filter() {
|
||||
let mut config = LogConfig::default();
|
||||
|
||||
config.level = "error".to_string();
|
||||
let config = LogConfig {
|
||||
level: "error".to_string(),
|
||||
..Default::default()
|
||||
};
|
||||
assert_eq!(config.to_level_filter(), log::LevelFilter::Error);
|
||||
|
||||
config.level = "warn".to_string();
|
||||
let config = LogConfig {
|
||||
level: "warn".to_string(),
|
||||
..Default::default()
|
||||
};
|
||||
assert_eq!(config.to_level_filter(), log::LevelFilter::Warn);
|
||||
|
||||
config.level = "info".to_string();
|
||||
let config = LogConfig {
|
||||
level: "info".to_string(),
|
||||
..Default::default()
|
||||
};
|
||||
assert_eq!(config.to_level_filter(), log::LevelFilter::Info);
|
||||
|
||||
config.level = "debug".to_string();
|
||||
let config = LogConfig {
|
||||
level: "debug".to_string(),
|
||||
..Default::default()
|
||||
};
|
||||
assert_eq!(config.to_level_filter(), log::LevelFilter::Debug);
|
||||
|
||||
config.level = "trace".to_string();
|
||||
let config = LogConfig {
|
||||
level: "trace".to_string(),
|
||||
..Default::default()
|
||||
};
|
||||
assert_eq!(config.to_level_filter(), log::LevelFilter::Trace);
|
||||
|
||||
// 无效级别回退到 info
|
||||
config.level = "invalid".to_string();
|
||||
let config = LogConfig {
|
||||
level: "invalid".to_string(),
|
||||
..Default::default()
|
||||
};
|
||||
assert_eq!(config.to_level_filter(), log::LevelFilter::Info);
|
||||
|
||||
// 禁用时返回 Off
|
||||
config.enabled = false;
|
||||
config.level = "debug".to_string();
|
||||
let config = LogConfig {
|
||||
enabled: false,
|
||||
level: "debug".to_string(),
|
||||
};
|
||||
assert_eq!(config.to_level_filter(), log::LevelFilter::Off);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user