From b8e4c983b79ee55526947affecde5d6f8a0f74a7 Mon Sep 17 00:00:00 2001 From: Artifizer Date: Sun, 6 Sep 2026 13:02:41 +0300 Subject: [PATCH] test: added a new unit tests to validate the cases like '"": "gts://gtx.x.test6.invalid_uri_body.bad_prefix.v1~"' Signed-off-by: Artifizer --- gts/src/ops.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/gts/src/ops.rs b/gts/src/ops.rs index cc0a7d9..4554047 100644 --- a/gts/src/ops.rs +++ b/gts/src/ops.rs @@ -3117,6 +3117,33 @@ mod tests { assert!(result.is_type_schema); } + #[test] + fn test_add_entity_schema_with_gts_uri_invalid_body_fails() { + let mut ops = GtsOps::new(None, None, 0); + // gts:// URI scheme is correct, but the body starts with "gtx." + // instead of "gts." — must be rejected. + let content = json!({ + "$id": "gts://gtx.x.test6.invalid_uri_body.bad_prefix.v1~", + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": {"type": "string"} + }, + "required": ["id"] + }); + + let result = ops.add_entity(&content, false); + assert!( + !result.ok, + "Schema with gts:// URI but non-gts body should fail" + ); + assert!( + result.error.contains("Unable to detect GTS ID"), + "Error should mention missing GTS ID, got: {}", + result.error + ); + } + // ============================================================================= // Additional test coverage for ops.rs functions // =============================================================================