test(config): erp-config 从 50 增至 66 个单元测试 — fallback_chain + model_to_resp + ThemeResp
Some checks failed
CI / rust-check (push) Has been cancelled
CI / rust-test (push) Has been cancelled
CI / frontend-build (push) Has been cancelled
CI / security-audit (push) Has been cancelled

- setting_service: 7 个测试(5 个 fallback_chain 作用域解析 + 2 个 model_to_resp 映射)
- theme_handler: 2 个测试(default_theme 默认值 + ThemeResp serde round-trip)
This commit is contained in:
iven
2026-04-28 18:31:01 +08:00
parent 26aa66d6e3
commit ace04ee56d
2 changed files with 124 additions and 2 deletions

View File

@@ -106,3 +106,30 @@ where
Ok(JsonResponse(ApiResponse::ok(req)))
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn default_theme_all_fields_none() {
let theme = default_theme();
assert!(theme.primary_color.is_none());
assert!(theme.logo_url.is_none());
assert!(theme.sidebar_style.is_none());
}
#[test]
fn theme_resp_serde_roundtrip() {
let theme = ThemeResp {
primary_color: Some("#1890ff".to_string()),
logo_url: None,
sidebar_style: Some("dark".to_string()),
};
let json = serde_json::to_string(&theme).unwrap();
let back: ThemeResp = serde_json::from_str(&json).unwrap();
assert_eq!(back.primary_color, Some("#1890ff".to_string()));
assert_eq!(back.logo_url, None);
assert_eq!(back.sidebar_style, Some("dark".to_string()));
}
}