Add test for SchemaBuilder::override_description. #327

This commit is contained in:
Sunli 2020-10-27 20:47:24 +08:00
parent 3052e13c8a
commit 8d2c8f9bcc

View File

@ -1,5 +1,6 @@
use async_graphql::*;
use async_std::stream::Stream;
use chrono::{DateTime, Utc};
#[async_std::test]
pub async fn test_object() {
@ -98,3 +99,45 @@ pub async fn test_subscription() {
})
);
}
#[async_std::test]
pub async fn test_override_description() {
/// Haha
#[derive(SimpleObject)]
struct Query {
value: i32,
value2: DateTime<Utc>,
}
let schema = Schema::build(
Query {
value: 100,
value2: Utc::now(),
},
EmptyMutation,
EmptySubscription,
)
.override_description::<Query>("Hehe")
.override_description::<DateTime<Utc>>("DT")
.finish();
assert_eq!(
schema
.execute(r#"{ __type(name: "Query") { description } }"#)
.await
.data,
value!({
"__type": { "description": "Hehe" }
})
);
assert_eq!(
schema
.execute(r#"{ __type(name: "DateTime") { description } }"#)
.await
.data,
value!({
"__type": { "description": "DT" }
})
);
}