test marshaller

This commit is contained in:
Kasper Juul Hermansen 2023-02-05 19:25:18 +01:00
parent c4ec6f0c97
commit c5dfcebaad
Signed by: kjuulh
GPG Key ID: 0F95C140730F2F23

View File

@ -112,6 +112,7 @@ impl Selection {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use serde::Serialize;
use super::query; use super::query;
@ -208,4 +209,26 @@ mod tests {
let b = root.select("b").build().unwrap(); let b = root.select("b").build().unwrap();
assert_eq!(b, r#"query{test{b}}"#.to_string()); assert_eq!(b, r#"query{test{b}}"#.to_string());
} }
#[derive(Serialize)]
struct CustomType {
pub name: String,
pub s: Option<Box<CustomType>>,
}
#[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())
}
} }