/
mcmare
/
RustAPI
Обзор
Документация
Войти
/
mcmare
/
RustAPI
Код
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
engine/tests/load_config.rs
43 строки
1 KB
mcmare
Add engine config models: connections, endpoints, field types, loader/validator
18 июл 2026, 16:14
18 июл 2026, 16:14
b8f5fda
Код
Авторство
О чём код?
use engine::config::{CrudOperation, EndpointKind, HttpMethod}; use std::path::Path; #[test] fn loads_valid_config() { let config = engine::load_config(Path::new("tests/fixtures/valid")).expect("config should load"); assert_eq!(config.connections.len(), 1); assert!(config.connections.contains_key("main_db")); assert_eq!(config.endpoints.len(), 4); let create = config .endpoints .iter() .find(|e| e.method == HttpMethod::Post && e.path == "/orders") .expect("create endpoint present"); match &create.kind { EndpointKind::Crud { operation, input, .. } => { assert_eq!(*operation, CrudOperation::Create); assert!(input.contains_key("name")); } _ => panic!("expected CRUD endpoint"), } let login = config .endpoints .iter() .find(|e| e.path == "/auth/login") .expect("script endpoint present"); match &login.kind { EndpointKind::Script { script_path } => { assert!(script_path.ends_with("scripts/login.rhai") || script_path.ends_with("scripts\\login.rhai")); } _ => panic!("expected script endpoint"), } } #[test] fn rejects_endpoint_with_unknown_connection() { let err = engine::load_config(Path::new("tests/fixtures/unknown_connection")) .expect_err("should fail: unknown connection reference"); assert!(err.to_string().contains("unknown connection")); }