This commit is contained in:
Sunli 2021-12-05 09:43:44 +08:00
parent ffedb9556b
commit c41f87c645
1 changed files with 20 additions and 7 deletions

View File

@ -47,7 +47,6 @@ enum UnreferencedInterface {
ObjectC(ObjectC), ObjectC(ObjectC),
} }
#[derive(Union)] #[derive(Union)]
enum ObjectUnion { enum ObjectUnion {
ObjectA(ObjectA), ObjectA(ObjectA),
@ -62,14 +61,16 @@ impl Query {
ObjectA { ObjectA {
id: 33, id: 33,
title: "haha".to_string(), title: "haha".to_string(),
}.into() }
.into()
} }
async fn explicit(&self) -> ExplicitInterface { async fn explicit(&self) -> ExplicitInterface {
ObjectA { ObjectA {
id: 40, id: 40,
title: "explicit".to_string(), title: "explicit".to_string(),
}.into() }
.into()
} }
} }
@ -111,13 +112,25 @@ pub async fn test_interface_exports_interfaces_on_object_type() {
.unwrap() .unwrap()
.data, .data,
) )
.unwrap(); .unwrap();
assert_eq!(resp.ty.name, "ObjectA"); assert_eq!(resp.ty.name, "ObjectA");
assert_eq!(resp.ty.kind, "OBJECT"); assert_eq!(resp.ty.kind, "OBJECT");
assert!(resp.ty.interfaces.iter().any(|i| i.name == "ExplicitInterface")); assert!(resp
assert!(resp.ty.interfaces.iter().any(|i| i.name == "ImplicitInterface")); .ty
assert!(!resp.ty.interfaces.iter().any(|i| i.name == "InvisibleInterface")); .interfaces
.iter()
.any(|i| i.name == "ExplicitInterface"));
assert!(resp
.ty
.interfaces
.iter()
.any(|i| i.name == "ImplicitInterface"));
assert!(!resp
.ty
.interfaces
.iter()
.any(|i| i.name == "InvisibleInterface"));
} }
#[tokio::test] #[tokio::test]