Fixed all tests.

This commit is contained in:
Sunli 2020-10-16 08:52:17 +08:00
parent ed2b73949a
commit 43bf61754a
7 changed files with 14 additions and 16 deletions

View File

@ -20,5 +20,5 @@ tide = { version = "0.13.0", default-features = false, features = ["h1-server"]
[dev-dependencies]
# Surf lacks multipart support
reqwest = { version = "0.10.8", default-features = false, features = ["json"] }
tokio = { version = "0.3.0", default-features = false, features = ["macros"] }
async-std = { version = "1.6.5", features = ["attributes", "tokio02"] }
serde_json = "1.0.59"

View File

@ -9,11 +9,11 @@ use async_graphql::*;
type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
#[tokio::test(max_threads = 1)]
#[async_std::test]
async fn quickstart() -> Result<()> {
let listen_addr = test_utils::find_listen_addr();
tokio::spawn(async move {
async_std::task::spawn(async move {
struct QueryRoot;
#[Object]
impl QueryRoot {
@ -63,11 +63,11 @@ async fn quickstart() -> Result<()> {
Ok(())
}
#[tokio::test(max_threads = 1)]
#[async_std::test]
async fn hello() -> Result<()> {
let listen_addr = test_utils::find_listen_addr();
tokio::spawn(async move {
async_std::task::spawn(async move {
struct Hello(String);
struct QueryRoot;
#[Object]
@ -136,11 +136,11 @@ async fn hello() -> Result<()> {
Ok(())
}
#[tokio::test(max_threads = 1)]
#[async_std::test]
async fn upload() -> Result<()> {
let listen_addr = test_utils::find_listen_addr();
tokio::spawn(async move {
async_std::task::spawn(async move {
struct QueryRoot;
#[Object]
impl QueryRoot {}

View File

@ -19,5 +19,5 @@ pub fn client() -> Client {
}
pub async fn wait_server_ready() {
tokio::time::delay_for(Duration::from_millis(300)).await;
async_std::task::sleep(Duration::from_millis(300)).await;
}

View File

@ -4,6 +4,7 @@ version = "2.0.3"
authors = ["sunli <scott_s829@163.com>", "Koxiaet"]
edition = "2018"
description = "async-graphql for warp"
publish = true
license = "MIT/Apache-2.0"
documentation = "https://docs.rs/async-graphql/"
homepage = "https://github.com/async-graphql/async-graphql"
@ -19,4 +20,4 @@ futures-util = { version = "0.3.6", default-features = false }
serde_json = "1.0.59"
[dev-dependencies]
tokio = { version = "0.3.0", default-features = false, features = ["macros"] }
tokio = { version = "0.3.0", default-features = false, features = ["macros", "rt-multi-thread", "time", "stream"] }

View File

@ -1,7 +1,6 @@
//! Async-graphql integration with Warp
#![allow(clippy::type_complexity)]
#![allow(clippy::needless_doctest_main)]
#![forbid(unsafe_code)]
mod batch_request;

View File

@ -31,15 +31,14 @@ use crate::{graphql_batch_opts, BadRequest, BatchResponse};
///
/// type MySchema = Schema<QueryRoot, EmptyMutation, EmptySubscription>;
///
/// #[tokio::main]
/// async fn main() {
/// tokio::runtime::Runtime::new().unwrap().block_on(async {
/// let schema = Schema::new(QueryRoot, EmptyMutation, EmptySubscription);
/// let filter = async_graphql_warp::graphql(schema)
/// .and_then(|(schema, request): (MySchema, async_graphql::Request)| async move {
/// Ok::<_, Infallible>(async_graphql_warp::Response::from(schema.execute(request).await))
/// });
/// warp::serve(filter).run(([0, 0, 0, 0], 8000)).await;
/// }
/// });
/// ```
pub fn graphql<Query, Mutation, Subscription>(
schema: Schema<Query, Mutation, Subscription>,

View File

@ -28,13 +28,12 @@ use warp::{Filter, Rejection, Reply};
/// }
/// }
///
/// #[tokio::main]
/// async fn main() {
/// tokio::runtime::Runtime::new().unwrap().block_on(async {
/// let schema = Schema::new(QueryRoot, EmptyMutation, SubscriptionRoot);
/// let filter = async_graphql_warp::graphql_subscription(schema)
/// .or(warp::any().map(|| "Hello, World!"));
/// warp::serve(filter).run(([0, 0, 0, 0], 8000)).await;
/// }
/// });
/// ```
pub fn graphql_subscription<Query, Mutation, Subscription>(
schema: Schema<Query, Mutation, Subscription>,