Switch the async runtime used for testing to Tokio.

This commit is contained in:
Sunli 2021-03-12 12:47:24 +08:00
parent e77fc7d914
commit 4f47703118
52 changed files with 172 additions and 175 deletions

View File

@ -77,7 +77,7 @@ futures-timer = { version = "3.0.2", optional = true }
futures-channel = { version = "0.3.8", optional = true }
[dev-dependencies]
async-std = { version = "1.6.5", features = ["attributes"] }
tokio = { version = "1.3.0", features = ["macros", "rt", "sync", "time"] }
futures-channel = "0.3.8"
[package.metadata.docs.rs]

View File

@ -650,7 +650,7 @@ impl<'a> ContextBase<'a, &'a Positioned<Field>> {
/// }
/// }
///
/// async_std::task::block_on(async move {
/// tokio::runtime::Runtime::new().unwrap().block_on(async move {
/// let schema = Schema::new(Query, EmptyMutation, EmptySubscription);
/// assert!(schema.execute("{ obj { a b c }}").await.is_ok());
/// assert!(schema.execute("{ obj { a ... { b c } }}").await.is_ok());

View File

@ -32,7 +32,7 @@
//! }
//! }
//!
//! async_std::task::block_on(async move {
//! tokio::runtime::Runtime::new().unwrap().block_on(async move {
//! let schema = Schema::new(Query, EmptyMutation, EmptySubscription);
//! let query = r#"
//! {
@ -249,7 +249,7 @@ mod tests {
}
}
#[async_std::test]
#[tokio::test]
async fn test_dataloader() {
let loader = Arc::new(DataLoader::new(MyLoader).max_batch_size(10));
assert_eq!(
@ -279,7 +279,7 @@ mod tests {
);
}
#[async_std::test]
#[tokio::test]
async fn test_duplicate_keys() {
let loader = Arc::new(DataLoader::new(MyLoader).max_batch_size(10));
assert_eq!(

View File

@ -72,7 +72,7 @@ mod tests {
}
}
#[async_std::test]
#[tokio::test]
async fn analyzer() {
let schema = Schema::build(Query, EmptyMutation, EmptySubscription)
.extension(extensions::Analyzer)

View File

@ -116,7 +116,7 @@ impl<T: CacheStorage> Extension for ApolloPersistedQueriesExtension<T> {
#[cfg(test)]
mod tests {
#[async_std::test]
#[tokio::test]
async fn test() {
use super::*;
use crate::*;

View File

@ -50,7 +50,7 @@ impl TracingConfig {
/// "span root"
/// );
///
/// async_std::task::block_on(async move {
/// tokio::runtime::Runtime::new().unwrap().block_on(async move {
/// let request = Request::new("{ value }")
/// .data(TracingConfig::default().parent_span(root_span));
/// schema.execute(request).await;

View File

@ -348,7 +348,7 @@ pub type FieldResult<T> = Result<T>;
/// }
/// }
///
/// async_std::task::block_on(async move {
/// tokio::runtime::Runtime::new().unwrap().block_on(async move {
/// let schema = Schema::new(QueryRoot { value: 10 }, EmptyMutation, EmptySubscription);
/// let res = schema.execute(r#"{
/// value
@ -406,7 +406,7 @@ pub type FieldResult<T> = Result<T>;
/// }
/// }
///
/// async_std::task::block_on(async move {
/// tokio::runtime::Runtime::new().unwrap().block_on(async move {
/// let schema = Schema::new(QueryRoot, EmptyMutation, EmptySubscription);
/// let res = schema.execute("{ objs { name } }").await.into_result().unwrap().data;
/// assert_eq!(res, value!({
@ -463,7 +463,7 @@ pub use async_graphql_derive::Object;
/// value: i32,
/// }
///
/// async_std::task::block_on(async move {
/// tokio::runtime::Runtime::new().unwrap().block_on(async move {
/// let schema = Schema::new(QueryRoot{ value: 10 }, EmptyMutation, EmptySubscription);
/// let res = schema.execute("{ value }").await.into_result().unwrap().data;
/// assert_eq!(res, value!({
@ -526,7 +526,7 @@ pub use async_graphql_derive::SimpleObject;
/// }
/// }
///
/// async_std::task::block_on(async move {
/// tokio::runtime::Runtime::new().unwrap().block_on(async move {
/// let schema = Schema::new(QueryRoot{ value1: MyEnum::A, value2: MyEnum::B }, EmptyMutation, EmptySubscription);
/// let res = schema.execute("{ value1 value2 }").await.into_result().unwrap().data;
/// assert_eq!(res, value!({ "value1": "A", "value2": "b" }));
@ -583,7 +583,7 @@ pub use async_graphql_derive::Enum;
/// }
/// }
///
/// async_std::task::block_on(async move {
/// tokio::runtime::Runtime::new().unwrap().block_on(async move {
/// let schema = Schema::new(QueryRoot, EmptyMutation, EmptySubscription);
/// let res = schema.execute(r#"
/// {
@ -713,7 +713,7 @@ pub use async_graphql_derive::InputObject;
/// }
/// }
///
/// async_std::task::block_on(async move {
/// tokio::runtime::Runtime::new().unwrap().block_on(async move {
/// let schema = Schema::build(QueryRoot, EmptyMutation, EmptySubscription).data("hello".to_string()).finish();
/// let res = schema.execute(r#"
/// {
@ -786,7 +786,7 @@ pub use async_graphql_derive::Interface;
/// }
/// }
///
/// async_std::task::block_on(async move {
/// tokio::runtime::Runtime::new().unwrap().block_on(async move {
/// let schema = Schema::build(QueryRoot, EmptyMutation, EmptySubscription).data("hello".to_string()).finish();
/// let res = schema.execute(r#"
/// {
@ -899,7 +899,7 @@ pub use async_graphql_derive::Scalar;
/// }
/// }
///
/// async_std::task::block_on(async move {
/// tokio::runtime::Runtime::new().unwrap().block_on(async move {
/// let schema = Schema::build(QueryRoot, EmptyMutation, EmptySubscription).data("hello".to_string()).finish();
///
/// let res = schema.execute("{ value }").await.into_result().unwrap().data;
@ -1047,7 +1047,7 @@ pub use async_graphql_derive::MergedSubscription;
/// obj: MyObj,
/// }
///
/// async_std::task::block_on(async move {
/// tokio::runtime::Runtime::new().unwrap().block_on(async move {
/// let schema = Schema::new(Query::default(), EmptyMutation, EmptySubscription);
/// assert_eq!(
/// schema

View File

@ -70,7 +70,7 @@ fn find<'a>(
mod tests {
use crate::*;
#[async_std::test]
#[tokio::test]
async fn test_look_ahead() {
#[derive(SimpleObject)]
#[graphql(internal)]

View File

@ -20,13 +20,12 @@
/// }
/// }
///
/// #[async_std::main]
/// async fn main() {
/// tokio::runtime::Runtime::new().unwrap().block_on(async {
/// let schema = Schema::new(QueryRoot, EmptyMutation, EmptySubscription);
/// assert_eq!(schema.execute("{ value1 }").await.into_result().unwrap().cache_control, CacheControl { public: true, max_age: 30 });
/// assert_eq!(schema.execute("{ value2 }").await.into_result().unwrap().cache_control, CacheControl { public: false, max_age: 60 });
/// assert_eq!(schema.execute("{ value1 value2 }").await.into_result().unwrap().cache_control, CacheControl { public: false, max_age: 30 });
/// }
/// });
/// ```
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub struct CacheControl {

View File

@ -77,7 +77,7 @@ pub trait ScalarType: Sized + Send {
/// }
/// }
///
/// async_std::task::block_on(async move {
/// tokio::runtime::Runtime::new().unwrap().block_on(async move {
/// let schema = Schema::new(Query, EmptyMutation, EmptySubscription);
/// let res = schema.execute(r#"{ value(input: {a: 10, b: {v1: 1, v2: 2} }) }"#).await.into_result().unwrap().data;
/// assert_eq!(res, value!({

View File

@ -67,8 +67,7 @@ pub struct EmptyFields;
/// }
/// }
///
/// #[async_std::main]
/// async fn main() {
/// tokio::runtime::Runtime::new().unwrap().block_on(async {
/// let schema = Schema::new(QueryRoot, EmptyMutation, EmptySubscription);
///
/// assert_eq!(schema.execute("{ numbers(first: 2) { edges { node diff } } }").await.into_result().unwrap().data, value!({
@ -88,7 +87,7 @@ pub struct EmptyFields;
/// ]
/// },
/// }));
/// }
/// });
/// ```
pub async fn query<Cursor, Node, ConnectionFields, EdgeFields, F, R>(
after: Option<String>,

View File

@ -36,7 +36,7 @@ mod test {
use crate::*;
use std::borrow::Cow;
#[async_std::test]
#[tokio::test]
async fn test_cow_type() {
struct Query {
obj: MyObj,

View File

@ -106,7 +106,7 @@ mod test {
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[async_std::test]
#[tokio::test]
async fn test_json_type() {
#[derive(Serialize, Deserialize)]
struct MyStruct {
@ -138,7 +138,7 @@ mod test {
);
}
#[async_std::test]
#[tokio::test]
async fn test_output_json_type() {
#[derive(Serialize)]
struct MyStruct {

View File

@ -28,8 +28,7 @@ use crate::{registry, InputType, InputValueError, InputValueResult, Type, Value}
/// }
/// }
///
/// #[async_std::main]
/// async fn main() {
/// tokio::runtime::Runtime::new().unwrap().block_on(async {
/// let schema = Schema::new(Query, EmptyMutation, EmptySubscription);
/// let query = r#"
/// {
@ -45,7 +44,7 @@ use crate::{registry, InputType, InputValueError, InputValueResult, Type, Value}
/// "v3": 2,
/// })
/// );
/// }
/// });
/// ```
#[allow(missing_docs)]
#[derive(Copy, Clone, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]

View File

@ -40,7 +40,7 @@ where
mod test {
use crate::*;
#[async_std::test]
#[tokio::test]
async fn test_string_number() {
struct Query;

View File

@ -1,6 +1,6 @@
use async_graphql::*;
#[async_std::test]
#[tokio::test]
pub async fn test_batch_request() {
struct Query;

View File

@ -1,7 +1,7 @@
use async_graphql::connection::*;
use async_graphql::*;
#[async_std::test]
#[tokio::test]
pub async fn test_connection_additional_fields() {
struct QueryRoot;

View File

@ -1,6 +1,6 @@
use async_graphql::*;
#[async_std::test]
#[tokio::test]
pub async fn test_default_value_arg() {
struct Query;
@ -47,7 +47,7 @@ pub async fn test_default_value_arg() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_default_value_inputobject() {
#[derive(InputObject)]
struct MyInput {

View File

@ -1,6 +1,6 @@
use async_graphql::*;
#[async_std::test]
#[tokio::test]
pub async fn test_directive_skip() {
struct QueryRoot;
@ -30,7 +30,7 @@ pub async fn test_directive_skip() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_directive_include() {
struct QueryRoot;
@ -60,7 +60,7 @@ pub async fn test_directive_include() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_directive_ifdef() {
struct QueryRoot;

View File

@ -1,6 +1,6 @@
use async_graphql::*;
#[async_std::test]
#[tokio::test]
pub async fn test_enum_type() {
#[derive(Enum, Copy, Clone, Eq, PartialEq)]
enum MyEnum {
@ -49,7 +49,7 @@ pub async fn test_enum_type() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_enum_derive_and_item_attributes() {
use serde::Deserialize;
@ -71,7 +71,7 @@ pub async fn test_enum_derive_and_item_attributes() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_remote_enum() {
#[derive(Enum, Copy, Clone, Eq, PartialEq)]
#[graphql(remote = "remote::RemoteEnum")]

View File

@ -1,6 +1,6 @@
use async_graphql::*;
#[async_std::test]
#[tokio::test]
pub async fn test_error_extensions() {
struct Query;

View File

@ -3,7 +3,7 @@ use async_graphql::*;
use spin::Mutex;
use std::sync::Arc;
#[async_std::test]
#[tokio::test]
pub async fn test_extension_ctx() {
#[derive(Default, Clone)]
struct MyData(Arc<Mutex<i32>>);

View File

@ -6,7 +6,7 @@ use std::convert::Infallible;
use async_graphql::dataloader::{DataLoader, Loader};
use async_graphql::*;
#[async_std::test]
#[tokio::test]
pub async fn test_nested_key() {
#[derive(InputObject)]
struct MyInputA {
@ -66,7 +66,7 @@ pub async fn test_nested_key() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_federation() {
struct User {
id: ID,
@ -151,7 +151,7 @@ pub async fn test_federation() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_find_entity_with_context() {
struct MyLoader;

View File

@ -3,7 +3,7 @@
use async_graphql::*;
use futures_util::stream::{Stream, StreamExt};
#[async_std::test]
#[tokio::test]
pub async fn test_field_features() {
#[derive(SimpleObject)]
struct MyObj {

View File

@ -1,6 +1,6 @@
use async_graphql::*;
#[async_std::test]
#[tokio::test]
pub async fn test_field_merge() {
struct Query;
@ -41,7 +41,7 @@ pub async fn test_field_merge() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_field_object_merge() {
#[derive(SimpleObject)]
struct MyObject {
@ -83,7 +83,7 @@ pub async fn test_field_object_merge() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_field_object_merge2() {
#[derive(SimpleObject)]
struct MyObject {

View File

@ -1,7 +1,7 @@
use async_graphql::*;
use futures_util::stream::{Stream, StreamExt};
#[async_std::test]
#[tokio::test]
pub async fn test_generic_object() {
struct MyObj<T> {
value: T,
@ -49,7 +49,7 @@ pub async fn test_generic_object() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_input_object_generic() {
#[derive(InputObject)]
#[graphql(
@ -148,7 +148,7 @@ pub async fn test_input_object_generic() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_generic_simple_object() {
#[derive(SimpleObject)]
#[graphql(concrete(name = "MyObjIntString", params(i32, String)))]
@ -251,7 +251,7 @@ pub async fn test_generic_simple_object() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_generic_subscription() {
struct MySubscription<T> {
values: Vec<T>,

View File

@ -57,7 +57,7 @@ impl Guard for AgeGuard {
}
}
#[async_std::test]
#[tokio::test]
pub async fn test_guard_simple_rule() {
#[derive(SimpleObject)]
struct Query {
@ -134,7 +134,7 @@ pub async fn test_guard_simple_rule() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_guard_and_operator() {
#[derive(SimpleObject)]
struct Query {
@ -218,7 +218,7 @@ pub async fn test_guard_and_operator() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_guard_or_operator() {
#[derive(SimpleObject)]
struct Query {
@ -287,7 +287,7 @@ pub async fn test_guard_or_operator() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_guard_chain_operator() {
#[derive(SimpleObject)]
struct Query {
@ -396,7 +396,7 @@ pub async fn test_guard_chain_operator() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_guard_race_operator() {
#[derive(SimpleObject)]
struct Query {

View File

@ -1,6 +1,6 @@
use async_graphql::*;
#[async_std::test]
#[tokio::test]
pub async fn test_input_object_default_value() {
#[derive(InputObject)]
struct MyInput {
@ -87,7 +87,7 @@ pub async fn test_input_object_default_value() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_inputobject_derive_and_item_attributes() {
use serde::Deserialize;
@ -103,7 +103,7 @@ pub async fn test_inputobject_derive_and_item_attributes() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_inputobject_flatten_recursive() {
#[derive(InputObject, Debug, Eq, PartialEq)]
struct A {
@ -230,7 +230,7 @@ pub async fn test_inputobject_flatten_recursive() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_inputobject_flatten_multiple() {
#[derive(InputObject, Debug, Eq, PartialEq)]
struct A {
@ -288,7 +288,7 @@ pub async fn test_inputobject_flatten_multiple() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_input_object_skip_field() {
#[derive(InputObject)]
struct MyInput2 {
@ -319,7 +319,7 @@ pub async fn test_input_object_skip_field() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_box_input_object() {
#[derive(InputObject)]
struct MyInput {

View File

@ -4,7 +4,7 @@ use async_graphql::validators::{
};
use async_graphql::*;
#[async_std::test]
#[tokio::test]
pub async fn test_input_validator_string_min_length() {
struct QueryRoot;
@ -120,7 +120,7 @@ pub async fn test_input_validator_string_min_length() {
}
}
#[async_std::test]
#[tokio::test]
pub async fn test_input_validator_string_max_length() {
struct QueryRoot;
@ -230,7 +230,7 @@ pub async fn test_input_validator_string_max_length() {
}
}
#[async_std::test]
#[tokio::test]
pub async fn test_input_validator_string_email() {
struct QueryRoot;
@ -370,7 +370,7 @@ pub async fn test_input_validator_string_email() {
}
}
#[async_std::test]
#[tokio::test]
pub async fn test_input_validator_string_mac() {
struct QueryRootWithColon;
struct QueryRootWithoutColon;
@ -660,7 +660,7 @@ pub async fn test_input_validator_string_mac() {
}
}
#[async_std::test]
#[tokio::test]
pub async fn test_input_validator_int_range() {
struct QueryRoot;
@ -762,7 +762,7 @@ pub async fn test_input_validator_int_range() {
}
}
#[async_std::test]
#[tokio::test]
pub async fn test_input_validator_int_less_than() {
struct QueryRoot;
@ -867,7 +867,7 @@ pub async fn test_input_validator_int_less_than() {
}
}
#[async_std::test]
#[tokio::test]
pub async fn test_input_validator_int_greater_than() {
struct QueryRoot;
@ -974,7 +974,7 @@ pub async fn test_input_validator_int_greater_than() {
}
}
#[async_std::test]
#[tokio::test]
pub async fn test_input_validator_int_nonzero() {
struct QueryRoot;
@ -1074,7 +1074,7 @@ pub async fn test_input_validator_int_nonzero() {
}
}
#[async_std::test]
#[tokio::test]
pub async fn test_input_validator_int_equal() {
struct QueryRoot;
@ -1178,7 +1178,7 @@ pub async fn test_input_validator_int_equal() {
}
}
#[async_std::test]
#[tokio::test]
pub async fn test_input_validator_list_max_length() {
struct QueryRoot;
@ -1294,7 +1294,7 @@ pub async fn test_input_validator_list_max_length() {
}
}
#[async_std::test]
#[tokio::test]
pub async fn test_input_validator_list_min_length() {
struct QueryRoot;
@ -1410,7 +1410,7 @@ pub async fn test_input_validator_list_min_length() {
}
}
#[async_std::test]
#[tokio::test]
pub async fn test_input_validator_operator_or() {
struct QueryRoot;
@ -1534,7 +1534,7 @@ pub async fn test_input_validator_operator_or() {
}
}
#[async_std::test]
#[tokio::test]
pub async fn test_input_validator_operator_and() {
struct QueryRoot;
@ -1651,7 +1651,7 @@ pub async fn test_input_validator_operator_and() {
}
}
#[async_std::test]
#[tokio::test]
pub async fn test_input_validator_variable() {
struct QueryRoot;

View File

@ -1,6 +1,6 @@
use async_graphql::*;
#[async_std::test]
#[tokio::test]
pub async fn test_input_value_custom_error() {
struct Query;

View File

@ -1,6 +1,6 @@
use async_graphql::*;
#[async_std::test]
#[tokio::test]
pub async fn test_interface_simple_object() {
#[derive(SimpleObject)]
struct MyObj {
@ -45,7 +45,7 @@ pub async fn test_interface_simple_object() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_interface_simple_object2() {
#[derive(SimpleObject)]
struct MyObj {
@ -90,7 +90,7 @@ pub async fn test_interface_simple_object2() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_multiple_interfaces() {
struct MyObj;
@ -158,7 +158,7 @@ pub async fn test_multiple_interfaces() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_multiple_objects_in_multiple_interfaces() {
struct MyObjOne;
@ -238,7 +238,7 @@ pub async fn test_multiple_objects_in_multiple_interfaces() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_interface_field_result() {
struct MyObj;
@ -282,7 +282,7 @@ pub async fn test_interface_field_result() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_interface_field_method() {
struct A;
@ -332,7 +332,7 @@ pub async fn test_interface_field_method() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_interface_implement_other_interface() {
#[derive(Interface)]
#[graphql(field(name = "id", type = "ID"))]
@ -398,7 +398,7 @@ pub async fn test_interface_implement_other_interface() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_issue_330() {
#[derive(Interface)]
#[graphql(field(

View File

@ -1,5 +1,5 @@
use async_graphql::*;
use async_std::stream::{self, Stream};
use futures_util::stream::{self, Stream};
#[derive(Clone, Debug)]
struct Circle {
@ -171,11 +171,11 @@ impl Subscription {
&self,
#[graphql(default = 1)] step: i32,
) -> impl Stream<Item = i32> {
stream::once(step)
stream::once(async move { step })
}
}
// #[async_std::test]
// #[tokio::test]
// pub async fn test_introspection_schema() {
// let schema = Schema::new(Query, Mutation, Subscription);
@ -219,7 +219,7 @@ impl Subscription {
// assert_eq!(res, res_json)
// }
// #[async_std::test]
// #[tokio::test]
// pub async fn test_introspection_documentation() {
// let schema = Schema::new(Query, EmptyMutation, EmptySubscription);
//
@ -286,7 +286,7 @@ impl Subscription {
// assert_eq!(res, res_json)
// }
#[async_std::test]
#[tokio::test]
pub async fn test_introspection_deprecation() {
let schema = Schema::new(Query, EmptyMutation, EmptySubscription);
@ -543,7 +543,7 @@ pub async fn test_introspection_deprecation() {
assert_eq!(res, res_json);
}
#[async_std::test]
#[tokio::test]
pub async fn test_introspection_type_kind() {
let schema = Schema::new(Query, Mutation, EmptySubscription);
@ -702,7 +702,7 @@ pub async fn test_introspection_type_kind() {
assert_eq!(res, res_json);
}
#[async_std::test]
#[tokio::test]
pub async fn test_introspection_scalar() {
let schema = Schema::new(Query, Mutation, EmptySubscription);
@ -729,7 +729,7 @@ pub async fn test_introspection_scalar() {
assert_eq!(res, res_json)
}
#[async_std::test]
#[tokio::test]
pub async fn test_introspection_union() {
let schema = Schema::new(Query, Mutation, EmptySubscription);
@ -765,7 +765,7 @@ pub async fn test_introspection_union() {
assert_eq!(res, res_json)
}
#[async_std::test]
#[tokio::test]
pub async fn test_introspection_interface() {
let schema = Schema::new(Query, EmptyMutation, EmptySubscription);
@ -843,7 +843,7 @@ pub async fn test_introspection_interface() {
assert_eq!(res, res_json);
}
#[async_std::test]
#[tokio::test]
pub async fn test_introspection_enum() {
let schema = Schema::new(Query, Mutation, EmptySubscription);
@ -892,7 +892,7 @@ pub async fn test_introspection_enum() {
assert_eq!(res, res_json)
}
#[async_std::test]
#[tokio::test]
pub async fn test_introspection_input_object() {
let schema = Schema::new(Query, Mutation, EmptySubscription);
@ -925,7 +925,7 @@ pub async fn test_introspection_input_object() {
assert_eq!(res, res_json)
}
#[async_std::test]
#[tokio::test]
pub async fn test_introspection_mutation() {
let schema = Schema::new(Query, Mutation, EmptySubscription);
@ -973,7 +973,7 @@ pub async fn test_introspection_mutation() {
assert_eq!(res, res_json)
}
#[async_std::test]
#[tokio::test]
pub async fn test_introspection_subscription() {
let schema = Schema::new(Query, EmptyMutation, Subscription);
@ -1021,7 +1021,7 @@ pub async fn test_introspection_subscription() {
assert_eq!(res, res_json)
}
// #[async_std::test]
// #[tokio::test]
// pub async fn test_introspection_full() {
// let schema = Schema::new(Query, EmptyMutation, Subscription);
//

View File

@ -1,7 +1,7 @@
use async_graphql::*;
use serde::Deserialize;
#[async_std::test]
#[tokio::test]
pub async fn test_type_visible() {
#[derive(SimpleObject)]
#[graphql(visible = false)]
@ -67,7 +67,7 @@ pub async fn test_type_visible() {
.is_none());
}
#[async_std::test]
#[tokio::test]
pub async fn test_field_visible() {
#[derive(SimpleObject)]
struct MyObj {
@ -146,7 +146,7 @@ pub async fn test_field_visible() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_enum_value_visible() {
#[derive(Enum, Eq, PartialEq, Copy, Clone)]
enum MyEnum {
@ -204,7 +204,7 @@ pub async fn test_enum_value_visible() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_visible_fn() {
struct IsAdmin(bool);

View File

@ -1,7 +1,7 @@
use async_graphql::*;
use std::collections::HashMap;
#[async_std::test]
#[tokio::test]
pub async fn test_json_scalar() {
#[derive(serde::Serialize, serde::Deserialize)]
struct MyData(HashMap<String, i32>);

View File

@ -3,7 +3,7 @@ use std::cmp::Ordering;
use std::collections::{BTreeSet, HashSet, LinkedList, VecDeque};
//noinspection ALL
#[async_std::test]
#[tokio::test]
pub async fn test_list_type() {
#[derive(InputObject)]
struct MyInput {

View File

@ -1,6 +1,6 @@
use async_graphql::*;
#[async_std::test]
#[tokio::test]
pub async fn test_maybe_undefined_type() {
#[derive(InputObject)]
struct MyInput {

View File

@ -16,7 +16,7 @@ struct Object3 {
c: i32,
}
#[async_std::test]
#[tokio::test]
pub async fn test_merged_object() {
type MyObj =
MergedObject<Object1, MergedObject<Object2, MergedObject<Object3, MergedObjectTail>>>;
@ -55,7 +55,7 @@ pub async fn test_merged_object() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_merged_object_macro() {
#[derive(MergedObject)]
struct MyObj(Object1, Object2, Object3);
@ -83,7 +83,7 @@ pub async fn test_merged_object_macro() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_merged_object_derive() {
#[derive(MergedObject)]
struct MyObj(Object1, Object2, Object3);
@ -111,7 +111,7 @@ pub async fn test_merged_object_derive() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_merged_object_default() {
mod a {
use super::*;
@ -157,7 +157,7 @@ pub async fn test_merged_object_default() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_merged_subscription() {
#[derive(Default)]
struct Subscription1;
@ -226,7 +226,7 @@ pub async fn test_merged_subscription() {
}
}
#[async_std::test]
#[tokio::test]
pub async fn test_merged_entity() {
#[derive(SimpleObject)]
struct Fruit {
@ -291,7 +291,7 @@ pub async fn test_merged_entity() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_issue_316() {
#[derive(SimpleObject)]
struct Fruit {
@ -337,7 +337,7 @@ pub async fn test_issue_316() {
assert!(schema.execute("{ _service { sdl }}").await.is_ok());
}
#[async_std::test]
#[tokio::test]
pub async fn test_issue_333() {
#[derive(SimpleObject)]
struct ObjectA<'a> {

View File

@ -1,6 +1,6 @@
use async_graphql::*;
#[async_std::test]
#[tokio::test]
pub async fn test_mut_args() {
struct Query;

View File

@ -1,9 +1,9 @@
use async_graphql::*;
use async_std::sync::Mutex;
use std::sync::Arc;
use std::time::Duration;
use tokio::sync::Mutex;
#[async_std::test]
#[tokio::test]
pub async fn test_mutation_execution_order() {
type List = Arc<Mutex<Vec<i32>>>;
@ -21,13 +21,13 @@ pub async fn test_mutation_execution_order() {
#[Object]
impl MutationRoot {
async fn append1(&self, ctx: &Context<'_>) -> bool {
async_std::task::sleep(Duration::from_secs(1)).await;
tokio::time::sleep(Duration::from_secs(1)).await;
ctx.data_unchecked::<List>().lock().await.push(1);
true
}
async fn append2(&self, ctx: &Context<'_>) -> bool {
async_std::task::sleep(Duration::from_millis(500)).await;
tokio::time::sleep(Duration::from_millis(500)).await;
ctx.data_unchecked::<List>().lock().await.push(2);
true
}
@ -42,7 +42,7 @@ pub async fn test_mutation_execution_order() {
assert_eq!(list.lock().await[1], 2);
}
#[async_std::test]
#[tokio::test]
pub async fn test_mutation_fragment() {
struct QueryRoot;

View File

@ -1,6 +1,6 @@
use async_graphql::*;
#[async_std::test]
#[tokio::test]
pub async fn test_optional_type() {
#[derive(InputObject)]
struct MyInput {

View File

@ -1,4 +1,4 @@
#[async_std::test]
#[tokio::test]
pub async fn test_object() {
macro_rules! test_data {
($test_name:ident) => {
@ -19,7 +19,7 @@ pub async fn test_object() {
test_data!(A);
}
#[async_std::test]
#[tokio::test]
pub async fn test_subscription() {
macro_rules! test_data {
($test_name:ident) => {
@ -41,7 +41,7 @@ pub async fn test_subscription() {
test_data!(A);
}
#[async_std::test]
#[tokio::test]
pub async fn test_scalar() {
macro_rules! test_data {
($test_name:ident) => {

View File

@ -1,7 +1,7 @@
use async_graphql::*;
use futures_util::stream::{Stream, StreamExt, TryStreamExt};
#[async_std::test]
#[tokio::test]
pub async fn test_input_value_custom_error() {
#[derive(Enum, Copy, Clone, Eq, PartialEq)]
#[allow(non_camel_case_types)]

View File

@ -1,7 +1,7 @@
use async_graphql::*;
use futures_util::stream::{Stream, StreamExt};
#[async_std::test]
#[tokio::test]
pub async fn test_enum() {
#[derive(Enum, Eq, PartialEq, Copy, Clone)]
#[graphql(rename_items = "camelCase")]
@ -32,7 +32,7 @@ pub async fn test_enum() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_simple_object() {
#[derive(SimpleObject)]
#[graphql(rename_fields = "UPPERCASE")]
@ -51,7 +51,7 @@ pub async fn test_simple_object() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_object() {
struct Query;
@ -73,7 +73,7 @@ pub async fn test_object() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_input_object() {
#[derive(InputObject)]
#[graphql(rename_fields = "snake_case")]
@ -103,7 +103,7 @@ pub async fn test_input_object() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_subscription() {
struct Query;

View File

@ -1,6 +1,6 @@
use async_graphql::*;
#[async_std::test]
#[tokio::test]
pub async fn test_fieldresult() {
struct Query;

View File

@ -9,7 +9,7 @@ mod test_mod {
}
}
#[async_std::test]
#[tokio::test]
pub async fn test_scalar_macro() {
scalar!(test_mod::MyValue, "MV", "DESC");

View File

@ -1,6 +1,6 @@
use async_graphql::*;
#[async_std::test]
#[tokio::test]
pub async fn test_schema_default() {
#[derive(Default)]
struct QueryRoot;

View File

@ -10,7 +10,7 @@ impl QueryRoot {
}
}
#[async_std::test]
#[tokio::test]
pub async fn test_subscription() {
#[derive(SimpleObject)]
struct Event {
@ -59,7 +59,7 @@ pub async fn test_subscription() {
}
}
#[async_std::test]
#[tokio::test]
pub async fn test_subscription_with_ctx_data() {
struct QueryRoot;
@ -109,7 +109,7 @@ pub async fn test_subscription_with_ctx_data() {
}
}
#[async_std::test]
#[tokio::test]
pub async fn test_subscription_with_token() {
struct QueryRoot;
@ -160,7 +160,7 @@ pub async fn test_subscription_with_token() {
}
}
#[async_std::test]
#[tokio::test]
pub async fn test_subscription_inline_fragment() {
#[derive(SimpleObject)]
struct Event {
@ -211,7 +211,7 @@ pub async fn test_subscription_inline_fragment() {
assert!(stream.next().await.is_none());
}
#[async_std::test]
#[tokio::test]
pub async fn test_subscription_fragment() {
#[derive(SimpleObject)]
struct Event {
@ -261,7 +261,7 @@ pub async fn test_subscription_fragment() {
assert!(stream.next().await.is_none());
}
#[async_std::test]
#[tokio::test]
pub async fn test_subscription_fragment2() {
#[derive(SimpleObject)]
struct Event {
@ -312,7 +312,7 @@ pub async fn test_subscription_fragment2() {
assert!(stream.next().await.is_none());
}
#[async_std::test]
#[tokio::test]
pub async fn test_subscription_error() {
struct Event {
value: i32,
@ -369,7 +369,7 @@ pub async fn test_subscription_error() {
assert!(stream.next().await.is_none());
}
#[async_std::test]
#[tokio::test]
pub async fn test_subscription_fieldresult() {
struct SubscriptionRoot;

View File

@ -4,7 +4,7 @@ use futures_channel::mpsc;
use futures_util::stream::{Stream, StreamExt};
use futures_util::SinkExt;
#[async_std::test]
#[tokio::test]
pub async fn test_subscription_ws_transport() {
struct QueryRoot;
@ -80,7 +80,7 @@ pub async fn test_subscription_ws_transport() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_subscription_ws_transport_with_token() {
struct Token(String);
@ -174,7 +174,7 @@ pub async fn test_subscription_ws_transport_with_token() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_subscription_ws_transport_error() {
struct Event {
value: i32,
@ -270,7 +270,7 @@ pub async fn test_subscription_ws_transport_error() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_subscription_init_error() {
struct QueryRoot;
@ -314,7 +314,7 @@ pub async fn test_subscription_init_error() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_subscription_too_many_initialisation_requests_error() {
struct QueryRoot;
@ -369,7 +369,7 @@ pub async fn test_subscription_too_many_initialisation_requests_error() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_query_over_websocket() {
struct QueryRoot;

View File

@ -4,7 +4,7 @@ use futures_channel::mpsc;
use futures_util::stream::{Stream, StreamExt};
use futures_util::SinkExt;
#[async_std::test]
#[tokio::test]
pub async fn test_subscription_ws_transport() {
struct QueryRoot;
@ -80,7 +80,7 @@ pub async fn test_subscription_ws_transport() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_subscription_ws_transport_with_token() {
struct Token(String);
@ -174,7 +174,7 @@ pub async fn test_subscription_ws_transport_with_token() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_subscription_ws_transport_error() {
struct Event {
value: i32,
@ -270,7 +270,7 @@ pub async fn test_subscription_ws_transport_error() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_subscription_too_many_initialisation_requests_error() {
struct QueryRoot;
@ -330,7 +330,7 @@ pub async fn test_subscription_too_many_initialisation_requests_error() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_query_over_websocket() {
struct QueryRoot;

View File

@ -1,6 +1,6 @@
use async_graphql::*;
#[async_std::test]
#[tokio::test]
pub async fn test_union_simple_object() {
#[derive(SimpleObject)]
struct MyObj {
@ -44,7 +44,7 @@ pub async fn test_union_simple_object() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_union_simple_object2() {
#[derive(SimpleObject)]
struct MyObj {
@ -88,7 +88,7 @@ pub async fn test_union_simple_object2() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_multiple_unions() {
struct MyObj;
@ -165,7 +165,7 @@ pub async fn test_multiple_unions() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_multiple_objects_in_multiple_unions() {
struct MyObjOne;
@ -242,7 +242,7 @@ pub async fn test_multiple_objects_in_multiple_unions() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_union_field_result() {
struct MyObj;
@ -285,7 +285,7 @@ pub async fn test_union_field_result() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_union_flatten() {
#[derive(SimpleObject)]
struct MyObj1 {

View File

@ -1,8 +1,8 @@
use async_graphql::*;
use async_std::stream::Stream;
use chrono::{DateTime, Utc};
use futures_util::stream::Stream;
#[async_std::test]
#[tokio::test]
pub async fn test_object() {
/// Haha
#[derive(Description, Default)]
@ -32,7 +32,7 @@ pub async fn test_object() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_object_with_lifetime() {
/// Haha
#[derive(Description, Default)]
@ -67,7 +67,7 @@ pub async fn test_object_with_lifetime() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_scalar() {
/// Haha
#[derive(Description, Default)]
@ -101,7 +101,7 @@ pub async fn test_scalar() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_subscription() {
struct Query;
@ -135,7 +135,7 @@ pub async fn test_subscription() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_override_description() {
/// Haha
#[derive(SimpleObject)]

View File

@ -1,7 +1,7 @@
use async_graphql::*;
use std::collections::HashMap;
#[async_std::test]
#[tokio::test]
pub async fn test_variables() {
struct QueryRoot;
@ -39,7 +39,7 @@ pub async fn test_variables() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_variable_default_value() {
struct QueryRoot;
@ -68,7 +68,7 @@ pub async fn test_variable_default_value() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_variable_no_value() {
struct QueryRoot;
@ -99,7 +99,7 @@ pub async fn test_variable_no_value() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_variable_null() {
struct QueryRoot;
@ -130,7 +130,7 @@ pub async fn test_variable_null() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_variable_in_input_object() {
#[derive(InputObject)]
struct MyInput {
@ -219,7 +219,7 @@ pub async fn test_variable_in_input_object() {
}
}
#[async_std::test]
#[tokio::test]
pub async fn test_variables_enum() {
#[derive(Enum, Eq, PartialEq, Copy, Clone)]
enum MyEnum {
@ -267,7 +267,7 @@ pub async fn test_variables_enum() {
);
}
#[async_std::test]
#[tokio::test]
pub async fn test_variables_json() {
struct QueryRoot;