MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / test_search_load_config2

Function test_search_load_config2

load_config/src/lib.rs:164–236  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

162
163 #[test]
164 fn test_search_load_config2() {
165 let temp_dir1 = TempDir::new().unwrap();
166 let temp_dir2 = TempDir::new().unwrap();
167 let dir1_path = temp_dir1.path().to_str().unwrap();
168 let dir2_path = temp_dir2.path().to_str().unwrap();
169
170 // Set up config in first directory
171 fs::write(
172 temp_dir1.path().join("app.toml"),
173 r#"
174base = "from_dir1"
175override1 = "dir1_value"
176common = "dir1_value"
177"#,
178 )
179 .unwrap();
180
181 // Set up config in second directory
182 fs::write(
183 temp_dir2.path().join("app.json"),
184 r#"{
185 "override1": "dir2_value",
186 "override2": "dir2_value",
187 "common": "dir2_value"
188 }"#,
189 )
190 .unwrap();
191
192 // Create leaf config file
193 let leaf_config = temp_dir1.path().join("leaf.json");
194 fs::write(
195 &leaf_config,
196 r#"{
197 "override2": "leaf_value",
198 "leaf_only": "leaf_value"
199 }"#,
200 )
201 .unwrap();
202
203 let default_toml = r#"
204base = "default"
205override1 = "default"
206override2 = "default"
207common = "default"
208"#;
209
210 let result = search_load_config(
211 "app",
212 &[dir1_path, dir2_path],
213 default_toml,
214 Some(leaf_config.to_str().unwrap()),
215 false,
216 );
217
218 // Test layered configuration
219 assert_eq!(result.extract_inner::<String>("base").unwrap(), "from_dir1");
220 assert_eq!(
221 result.extract_inner::<String>("override1").unwrap(),

Callers

nothing calls this directly

Calls 2

search_load_configFunction · 0.85
pathMethod · 0.80

Tested by

no test coverage detected