MCPcopy Create free account
hub / github.com/eventuallyconsultant/codegenr / resolve_reference_test

Function resolve_reference_test

codegenr/src/resolver.rs:235–266  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

233 },
234 "data2": [
235 1,2,3
236 ]
237 },
238 "myref": {
239 "data": "test"
240 }
241 });
242
243 assert_eq!(
244 fetch_reference_value(&json, &Some("/test/data1/value".into()))?,
245 Value::Number(serde_json::Number::from(42))
246 );
247
248 assert_eq!(fetch_reference_value(&json, &Some("/test/data1".into()))?, json!({ "value": 42 }));
249
250 let path: &str = "/test/not_existing_path";
251 let failed_test = fetch_reference_value(&json, &Some(path.into()));
252 let err = failed_test.expect_err("Should be an error");
253 assert_eq!(
254 err.to_string(),
255 "Key `not_existing_path` was not found in json part `{\"data1\":{\"value\":42},\"data2\":[1,2,3]}`."
256 );
257
258 Ok(())
259 }
260
261 #[test]
262 fn resolve_refs_test_0() -> Result<(), anyhow::Error> {
263 let json = json!({
264 "test": {
265 "$ref": "#/myref"
266 },
267 "myref": {
268 "data": "test"
269 }

Callers

nothing calls this directly

Calls 1

fetch_reference_valueFunction · 0.85

Tested by

no test coverage detected