tgqe 0.0.2

The Great Qin Empire —— A centralized system for integrating and summarizing common compiler front-end library errors and span error output libraries, with optional Ariadne integration.
/**

 *  - Copyright (c) 星灿长风v(Starwindv) 2026/08/03
 *  - License: BSD-3
 *  - Author: 星灿长风v(StarWindv)
 *  - Location: tgqe/src/modules/tests/config.rs
 */
use crate::channel::configure::TgqeConfig;

#[test]
fn env_override_parses_and_falls_back() {
    // SAFETY: 单线程测试, 无并发环境变量访问
    unsafe {
        std::env::set_var(
            "TGQE_RENDER_LIMIT",
            "12",
        );
        std::env::set_var(
            "TGQE_COMPACT",
            "false",
        );
        std::env::set_var(
            "TGQE_DB_FILE_FORMAT",
            "record-%Y%m%d",
        );
        std::env::set_var(
            "TGQE_DB_MAX_CONNECTIONS",
            "8",
        );
    }

    let config = TgqeConfig::load();

    #[cfg(feature = "renderer")]
    assert_eq!(config.render_limit, 12);
    #[cfg(feature = "renderer")]
    assert!(!config.compact);
    #[cfg(feature = "store-to-db")]
    assert_eq!(
        config.db_file_format,
        "record-%Y%m%d"
    );
    #[cfg(feature = "store-to-db")]
    assert_eq!(config.db_max_connections, 8);

    // 非法数值回退到默认值
    // SAFETY: 单线程测试, 无并发环境变量访问
    unsafe {
        std::env::set_var(
            "TGQE_RENDER_LIMIT",
            "abc",
        );
    }
    #[cfg(feature = "renderer")]
    assert_eq!(
        TgqeConfig::load().render_limit,
        30
    );
}