e9571_config_reader/
lib.rs

1use std::collections::HashMap;
2use std::fs::File;
3use std::io::Read;
4use std::path::Path;
5use serde_json;
6
7// 读取 config.json 并解析为 HashMap<String, String
8
9#[cfg(test)]
10mod tests {
11    use super::*;
12
13    #[test]
14    fn test_read_config() {
15        // 测试需要 config.json 存在,建议在测试前创建
16        match read_config() {
17            Ok(config) => {
18                assert!(config.contains_key("apiURL"));
19                assert!(config.contains_key("apiKey"));
20            }
21            Err(e) => panic!("Test failed: {}", e),
22        }
23    }
24}