From c5dfcebaad9c255b10ba8c6e4d4dba00821c8941 Mon Sep 17 00:00:00 2001 From: kjuulh Date: Sun, 5 Feb 2023 19:25:18 +0100 Subject: [PATCH] test marshaller --- crates/dagger-sdk/src/querybuilder.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/crates/dagger-sdk/src/querybuilder.rs b/crates/dagger-sdk/src/querybuilder.rs index 852e6df..9adf881 100644 --- a/crates/dagger-sdk/src/querybuilder.rs +++ b/crates/dagger-sdk/src/querybuilder.rs @@ -112,6 +112,7 @@ impl Selection { #[cfg(test)] mod tests { use pretty_assertions::assert_eq; + use serde::Serialize; use super::query; @@ -208,4 +209,26 @@ mod tests { let b = root.select("b").build().unwrap(); assert_eq!(b, r#"query{test{b}}"#.to_string()); } + + #[derive(Serialize)] + struct CustomType { + pub name: String, + pub s: Option>, + } + + #[test] + fn test_arg_custom_type() { + let input = CustomType { + name: "some-name".to_string(), + s: Some(Box::new(CustomType { + name: "some-other-name".to_string(), + s: None, + })), + }; + + let root = query().select("a").arg("arg", input).unwrap(); + let query = root.build().unwrap(); + + assert_eq!(query, r#"query{a(arg:"some-string")}"#.to_string()) + } }