From 6f449a0a43a1a3ae74f6b9a21a0bc38ac697cf65 Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Thu, 29 Jan 2026 15:16:36 +0000 Subject: [PATCH] Add test files: integration, conversion, validation tests --- tests/validation_tests.rs | 55 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tests/validation_tests.rs diff --git a/tests/validation_tests.rs b/tests/validation_tests.rs new file mode 100644 index 0000000..6ce4167 --- /dev/null +++ b/tests/validation_tests.rs @@ -0,0 +1,55 @@ +#[cfg(test)] +mod tests { + use config_forge::convert::infer_schema; + use serde_json::json; + + #[test] + fn test_infer_schema_string() { + let value = json!("test"); + let schema = infer_schema(&value); + assert_eq!(schema["type"], "string"); + } + + #[test] + fn test_infer_schema_number() { + let value = json!(42); + let schema = infer_schema(&value); + assert_eq!(schema["type"], "integer"); + } + + #[test] + fn test_infer_schema_boolean() { + let value = json!(true); + let schema = infer_schema(&value); + assert_eq!(schema["type"], "boolean"); + } + + #[test] + fn test_infer_schema_object() { + let value = json!({"name": "test", "value": 42}); + let schema = infer_schema(&value); + assert_eq!(schema["type"], "object"); + assert!(schema["properties"].is_object()); + } + + #[test] + fn test_infer_schema_array() { + let value = json!([1, 2, 3]); + let schema = infer_schema(&value); + assert_eq!(schema["type"], "array"); + } + + #[test] + fn test_infer_schema_nested() { + let value = json!({ + "user": { + "name": "test", + "age": 30 + } + }); + let schema = infer_schema(&value); + assert_eq!(schema["type"], "object"); + let props = schema["properties"].as_object().unwrap(); + assert!(props.contains_key("user")); + } +}