From 73c553cd283415aba3cd9157424b5d156eb4299a Mon Sep 17 00:00:00 2001
From: Maaz Ahmed <maaz.a@subcom.tech>
Date: Mon, 1 Jul 2024 11:41:02 +0530
Subject: [PATCH] test: new integration test for tuple structs

---
 tests/basic.rs | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/tests/basic.rs b/tests/basic.rs
index 3d74ba3..81789f1 100644
--- a/tests/basic.rs
+++ b/tests/basic.rs
@@ -13,6 +13,8 @@ use utoipa::{OpenApi, ToSchema};
     Options,
     SerdeSchema,
     EnumType,
+    TupleSchema,
+    TupleStruct,
 )))]
 struct ApiDocs;
 
@@ -55,6 +57,14 @@ enum Options {
     Three,
 }
 
+#[derive(ToSchema)]
+struct TupleSchema {
+    inner: TupleStruct,
+}
+
+#[derive(ToSchema)]
+struct TupleStruct(Options);
+
 #[derive(Debug, Serialize, Deserialize, ToSchema)]
 pub struct SerdeSchema {
     #[serde(flatten)]
@@ -194,3 +204,22 @@ fn validate_serde_schema_err() {
     }));
     assert!(result.is_err());
 }
+
+#[test]
+fn validate_tuple_schema() {
+    let schemas = get_schemas();
+    let validator =
+        schema_police::SchemaInspector::new_infer::<TupleSchema>(schemas, true).unwrap();
+    let result = validator.inspect(&serde_json::json!({
+        "inner": "One",
+    }));
+    assert_eq!(result, Ok(()));
+    let result = validator.inspect(&serde_json::json!({
+        "inner": "Two",
+    }));
+    assert_eq!(result, Ok(()));
+    let result = validator.inspect(&serde_json::json!({
+        "inner": "Three",
+    }));
+    assert_eq!(result, Ok(()));
+}
-- 
GitLab