Convert more tests to async (#558)
This commit is contained in:
parent
bdaa77053d
commit
961a07125f
4 changed files with 302 additions and 215 deletions
|
@ -84,8 +84,8 @@ mod interface {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
#[tokio::test]
|
||||
async fn test() {
|
||||
let schema = RootNode::new(
|
||||
Schema {
|
||||
pets: vec![
|
||||
|
@ -116,8 +116,9 @@ mod interface {
|
|||
|
||||
let vars = vec![].into_iter().collect();
|
||||
|
||||
let (result, errs) =
|
||||
crate::execute_sync(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
let (result, errs) = crate::execute(doc, None, &schema, &vars, &())
|
||||
.await
|
||||
.expect("Execution failed");
|
||||
|
||||
assert_eq!(errs, []);
|
||||
|
||||
|
@ -229,8 +230,8 @@ mod union {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_unions() {
|
||||
#[tokio::test]
|
||||
async fn test_unions() {
|
||||
let schema = RootNode::new(
|
||||
Schema {
|
||||
pets: vec![
|
||||
|
@ -263,8 +264,9 @@ mod union {
|
|||
|
||||
let vars = vec![].into_iter().collect();
|
||||
|
||||
let (result, errs) =
|
||||
crate::execute_sync(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
let (result, errs) = crate::execute(doc, None, &schema, &vars, &())
|
||||
.await
|
||||
.expect("Execution failed");
|
||||
|
||||
assert_eq!(errs, []);
|
||||
|
||||
|
|
|
@ -88,14 +88,15 @@ impl Root {
|
|||
}
|
||||
}
|
||||
|
||||
fn run_type_info_query<F>(doc: &str, f: F)
|
||||
async fn run_type_info_query<F>(doc: &str, f: F)
|
||||
where
|
||||
F: Fn((&Object<DefaultScalarValue>, &Vec<Value<DefaultScalarValue>>)) -> (),
|
||||
{
|
||||
let schema = RootNode::new(Root {}, EmptyMutation::<()>::new());
|
||||
|
||||
let (result, errs) =
|
||||
crate::execute_sync(doc, None, &schema, &Variables::new(), &()).expect("Execution failed");
|
||||
let (result, errs) = crate::execute(doc, None, &schema, &Variables::new(), &())
|
||||
.await
|
||||
.expect("Execution failed");
|
||||
|
||||
assert_eq!(errs, []);
|
||||
|
||||
|
@ -118,8 +119,8 @@ where
|
|||
f((type_info, values));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn default_name_introspection() {
|
||||
#[tokio::test]
|
||||
async fn default_name_introspection() {
|
||||
let doc = r#"
|
||||
{
|
||||
__type(name: "DefaultName") {
|
||||
|
@ -168,11 +169,12 @@ fn default_name_introspection() {
|
|||
.into_iter()
|
||||
.collect(),
|
||||
)));
|
||||
});
|
||||
})
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn named_introspection() {
|
||||
#[tokio::test]
|
||||
async fn named_introspection() {
|
||||
let doc = r#"
|
||||
{
|
||||
__type(name: "ANamedEnum") {
|
||||
|
@ -221,11 +223,12 @@ fn named_introspection() {
|
|||
.into_iter()
|
||||
.collect(),
|
||||
)));
|
||||
});
|
||||
})
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_trailing_comma_introspection() {
|
||||
#[tokio::test]
|
||||
async fn no_trailing_comma_introspection() {
|
||||
let doc = r#"
|
||||
{
|
||||
__type(name: "NoTrailingComma") {
|
||||
|
@ -274,11 +277,12 @@ fn no_trailing_comma_introspection() {
|
|||
.into_iter()
|
||||
.collect(),
|
||||
)));
|
||||
});
|
||||
})
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn enum_description_introspection() {
|
||||
#[tokio::test]
|
||||
async fn enum_description_introspection() {
|
||||
let doc = r#"
|
||||
{
|
||||
__type(name: "EnumDescription") {
|
||||
|
@ -327,11 +331,12 @@ fn enum_description_introspection() {
|
|||
.into_iter()
|
||||
.collect(),
|
||||
)));
|
||||
});
|
||||
})
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn enum_value_description_introspection() {
|
||||
#[tokio::test]
|
||||
async fn enum_value_description_introspection() {
|
||||
let doc = r#"
|
||||
{
|
||||
__type(name: "EnumValueDescription") {
|
||||
|
@ -380,11 +385,12 @@ fn enum_value_description_introspection() {
|
|||
.into_iter()
|
||||
.collect(),
|
||||
)));
|
||||
});
|
||||
})
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn enum_deprecation_introspection() {
|
||||
#[tokio::test]
|
||||
async fn enum_deprecation_introspection() {
|
||||
let doc = r#"
|
||||
{
|
||||
__type(name: "EnumDeprecation") {
|
||||
|
@ -439,11 +445,12 @@ fn enum_deprecation_introspection() {
|
|||
.into_iter()
|
||||
.collect(),
|
||||
)));
|
||||
});
|
||||
})
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn enum_deprecation_no_values_introspection() {
|
||||
#[tokio::test]
|
||||
async fn enum_deprecation_no_values_introspection() {
|
||||
let doc = r#"
|
||||
{
|
||||
__type(name: "EnumDeprecation") {
|
||||
|
@ -470,5 +477,6 @@ fn enum_deprecation_no_values_introspection() {
|
|||
);
|
||||
|
||||
assert_eq!(values.len(), 0);
|
||||
});
|
||||
})
|
||||
.await;
|
||||
}
|
||||
|
|
|
@ -100,14 +100,15 @@ impl Root {
|
|||
}
|
||||
}
|
||||
|
||||
fn run_type_info_query<F>(doc: &str, f: F)
|
||||
async fn run_type_info_query<F>(doc: &str, f: F)
|
||||
where
|
||||
F: Fn(&Object<DefaultScalarValue>, &Vec<Value<DefaultScalarValue>>) -> (),
|
||||
{
|
||||
let schema = RootNode::new(Root {}, EmptyMutation::<()>::new());
|
||||
|
||||
let (result, errs) =
|
||||
crate::execute_sync(doc, None, &schema, &Variables::new(), &()).expect("Execution failed");
|
||||
let (result, errs) = crate::execute(doc, None, &schema, &Variables::new(), &())
|
||||
.await
|
||||
.expect("Execution failed");
|
||||
|
||||
assert_eq!(errs, []);
|
||||
|
||||
|
@ -130,8 +131,8 @@ where
|
|||
f(type_info, fields);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn default_name_introspection() {
|
||||
#[tokio::test]
|
||||
async fn default_name_introspection() {
|
||||
let doc = r#"
|
||||
{
|
||||
__type(name: "DefaultName") {
|
||||
|
@ -212,7 +213,8 @@ fn default_name_introspection() {
|
|||
.into_iter()
|
||||
.collect(),
|
||||
)));
|
||||
});
|
||||
})
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -236,8 +238,8 @@ fn default_name_input_value() {
|
|||
assert_eq!(dv.field_two, "number two");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_trailing_comma_introspection() {
|
||||
#[tokio::test]
|
||||
async fn no_trailing_comma_introspection() {
|
||||
let doc = r#"
|
||||
{
|
||||
__type(name: "NoTrailingComma") {
|
||||
|
@ -318,11 +320,12 @@ fn no_trailing_comma_introspection() {
|
|||
.into_iter()
|
||||
.collect(),
|
||||
)));
|
||||
});
|
||||
})
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn derive_introspection() {
|
||||
#[tokio::test]
|
||||
async fn derive_introspection() {
|
||||
let doc = r#"
|
||||
{
|
||||
__type(name: "Derive") {
|
||||
|
@ -378,7 +381,8 @@ fn derive_introspection() {
|
|||
.into_iter()
|
||||
.collect(),
|
||||
)));
|
||||
});
|
||||
})
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -394,8 +398,8 @@ fn derive_derived() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn named_introspection() {
|
||||
#[tokio::test]
|
||||
async fn named_introspection() {
|
||||
let doc = r#"
|
||||
{
|
||||
__type(name: "ANamedInputObject") {
|
||||
|
@ -451,11 +455,12 @@ fn named_introspection() {
|
|||
.into_iter()
|
||||
.collect(),
|
||||
)));
|
||||
});
|
||||
})
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn description_introspection() {
|
||||
#[tokio::test]
|
||||
async fn description_introspection() {
|
||||
let doc = r#"
|
||||
{
|
||||
__type(name: "Description") {
|
||||
|
@ -511,11 +516,12 @@ fn description_introspection() {
|
|||
.into_iter()
|
||||
.collect(),
|
||||
)));
|
||||
});
|
||||
})
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn field_description_introspection() {
|
||||
#[tokio::test]
|
||||
async fn field_description_introspection() {
|
||||
let doc = r#"
|
||||
{
|
||||
__type(name: "FieldDescription") {
|
||||
|
@ -596,11 +602,12 @@ fn field_description_introspection() {
|
|||
.into_iter()
|
||||
.collect(),
|
||||
)));
|
||||
});
|
||||
})
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn field_with_defaults_introspection() {
|
||||
#[tokio::test]
|
||||
async fn field_with_defaults_introspection() {
|
||||
let doc = r#"
|
||||
{
|
||||
__type(name: "FieldWithDefaults") {
|
||||
|
@ -649,5 +656,6 @@ fn field_with_defaults_introspection() {
|
|||
.into_iter()
|
||||
.collect(),
|
||||
)));
|
||||
});
|
||||
})
|
||||
.await;
|
||||
}
|
||||
|
|
|
@ -126,14 +126,15 @@ impl TestType {
|
|||
}
|
||||
}
|
||||
|
||||
fn run_variable_query<F>(query: &str, vars: Variables<DefaultScalarValue>, f: F)
|
||||
async fn run_variable_query<F>(query: &str, vars: Variables<DefaultScalarValue>, f: F)
|
||||
where
|
||||
F: Fn(&Object<DefaultScalarValue>) -> (),
|
||||
{
|
||||
let schema = RootNode::new(TestType, EmptyMutation::<()>::new());
|
||||
|
||||
let (result, errs) =
|
||||
crate::execute_sync(query, None, &schema, &vars, &()).expect("Execution failed");
|
||||
let (result, errs) = crate::execute(query, None, &schema, &vars, &())
|
||||
.await
|
||||
.expect("Execution failed");
|
||||
|
||||
assert_eq!(errs, []);
|
||||
|
||||
|
@ -144,15 +145,15 @@ where
|
|||
f(obj);
|
||||
}
|
||||
|
||||
fn run_query<F>(query: &str, f: F)
|
||||
async fn run_query<F>(query: &str, f: F)
|
||||
where
|
||||
F: Fn(&Object<DefaultScalarValue>) -> (),
|
||||
{
|
||||
run_variable_query(query, Variables::new(), f);
|
||||
run_variable_query(query, Variables::new(), f).await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn inline_complex_input() {
|
||||
#[tokio::test]
|
||||
async fn inline_complex_input() {
|
||||
run_query(
|
||||
r#"{ fieldWithObjectInput(input: {a: "foo", b: ["bar"], c: "baz"}) }"#,
|
||||
|result: &Object<DefaultScalarValue>| {
|
||||
|
@ -163,11 +164,11 @@ fn inline_complex_input() {
|
|||
))
|
||||
);
|
||||
},
|
||||
);
|
||||
).await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn inline_parse_single_value_to_list() {
|
||||
#[tokio::test]
|
||||
async fn inline_parse_single_value_to_list() {
|
||||
run_query(
|
||||
r#"{ fieldWithObjectInput(input: {a: "foo", b: "bar", c: "baz"}) }"#,
|
||||
|result: &Object<DefaultScalarValue>| {
|
||||
|
@ -178,11 +179,11 @@ fn inline_parse_single_value_to_list() {
|
|||
))
|
||||
);
|
||||
},
|
||||
);
|
||||
).await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn inline_runs_from_input_value_on_scalar() {
|
||||
#[tokio::test]
|
||||
async fn inline_runs_from_input_value_on_scalar() {
|
||||
run_query(
|
||||
r#"{ fieldWithObjectInput(input: {c: "baz", d: "SerializedValue"}) }"#,
|
||||
|result: &Object<DefaultScalarValue>| {
|
||||
|
@ -193,11 +194,11 @@ fn inline_runs_from_input_value_on_scalar() {
|
|||
))
|
||||
);
|
||||
},
|
||||
);
|
||||
).await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variable_complex_input() {
|
||||
#[tokio::test]
|
||||
async fn variable_complex_input() {
|
||||
run_variable_query(
|
||||
r#"query q($input: TestInputObject) { fieldWithObjectInput(input: $input) }"#,
|
||||
vec![(
|
||||
|
@ -222,11 +223,11 @@ fn variable_complex_input() {
|
|||
))
|
||||
);
|
||||
},
|
||||
);
|
||||
).await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variable_parse_single_value_to_list() {
|
||||
#[tokio::test]
|
||||
async fn variable_parse_single_value_to_list() {
|
||||
run_variable_query(
|
||||
r#"query q($input: TestInputObject) { fieldWithObjectInput(input: $input) }"#,
|
||||
vec![(
|
||||
|
@ -251,11 +252,11 @@ fn variable_parse_single_value_to_list() {
|
|||
))
|
||||
);
|
||||
},
|
||||
);
|
||||
).await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variable_runs_from_input_value_on_scalar() {
|
||||
#[tokio::test]
|
||||
async fn variable_runs_from_input_value_on_scalar() {
|
||||
run_variable_query(
|
||||
r#"query q($input: TestInputObject) { fieldWithObjectInput(input: $input) }"#,
|
||||
vec![(
|
||||
|
@ -279,11 +280,11 @@ fn variable_runs_from_input_value_on_scalar() {
|
|||
))
|
||||
);
|
||||
},
|
||||
);
|
||||
).await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variable_error_on_nested_non_null() {
|
||||
#[tokio::test]
|
||||
async fn variable_error_on_nested_non_null() {
|
||||
let schema = RootNode::new(TestType, EmptyMutation::<()>::new());
|
||||
|
||||
let query = r#"query q($input: TestInputObject) { fieldWithObjectInput(input: $input) }"#;
|
||||
|
@ -302,7 +303,9 @@ fn variable_error_on_nested_non_null() {
|
|||
.into_iter()
|
||||
.collect();
|
||||
|
||||
let error = crate::execute_sync(query, None, &schema, &vars, &()).unwrap_err();
|
||||
let error = crate::execute(query, None, &schema, &vars, &())
|
||||
.await
|
||||
.unwrap_err();
|
||||
|
||||
assert_eq!(
|
||||
error,
|
||||
|
@ -313,8 +316,8 @@ fn variable_error_on_nested_non_null() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variable_error_on_incorrect_type() {
|
||||
#[tokio::test]
|
||||
async fn variable_error_on_incorrect_type() {
|
||||
let schema = RootNode::new(TestType, EmptyMutation::<()>::new());
|
||||
|
||||
let query = r#"query q($input: TestInputObject) { fieldWithObjectInput(input: $input) }"#;
|
||||
|
@ -322,7 +325,9 @@ fn variable_error_on_incorrect_type() {
|
|||
.into_iter()
|
||||
.collect();
|
||||
|
||||
let error = crate::execute_sync(query, None, &schema, &vars, &()).unwrap_err();
|
||||
let error = crate::execute(query, None, &schema, &vars, &())
|
||||
.await
|
||||
.unwrap_err();
|
||||
|
||||
assert_eq!(
|
||||
error,
|
||||
|
@ -333,8 +338,8 @@ fn variable_error_on_incorrect_type() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variable_error_on_omit_non_null() {
|
||||
#[tokio::test]
|
||||
async fn variable_error_on_omit_non_null() {
|
||||
let schema = RootNode::new(TestType, EmptyMutation::<()>::new());
|
||||
|
||||
let query = r#"query q($input: TestInputObject) { fieldWithObjectInput(input: $input) }"#;
|
||||
|
@ -352,7 +357,9 @@ fn variable_error_on_omit_non_null() {
|
|||
.into_iter()
|
||||
.collect();
|
||||
|
||||
let error = crate::execute_sync(query, None, &schema, &vars, &()).unwrap_err();
|
||||
let error = crate::execute(query, None, &schema, &vars, &())
|
||||
.await
|
||||
.unwrap_err();
|
||||
|
||||
assert_eq!(
|
||||
error,
|
||||
|
@ -363,8 +370,8 @@ fn variable_error_on_omit_non_null() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variable_multiple_errors_with_nesting() {
|
||||
#[tokio::test]
|
||||
async fn variable_multiple_errors_with_nesting() {
|
||||
let schema = RootNode::new(TestType, EmptyMutation::<()>::new());
|
||||
|
||||
let query =
|
||||
|
@ -383,7 +390,9 @@ fn variable_multiple_errors_with_nesting() {
|
|||
.into_iter()
|
||||
.collect();
|
||||
|
||||
let error = crate::execute_sync(query, None, &schema, &vars, &()).unwrap_err();
|
||||
let error = crate::execute(query, None, &schema, &vars, &())
|
||||
.await
|
||||
.unwrap_err();
|
||||
|
||||
assert_eq!(
|
||||
error,
|
||||
|
@ -400,8 +409,8 @@ fn variable_multiple_errors_with_nesting() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variable_error_on_additional_field() {
|
||||
#[tokio::test]
|
||||
async fn variable_error_on_additional_field() {
|
||||
let schema = RootNode::new(TestType, EmptyMutation::<()>::new());
|
||||
|
||||
let query = r#"query q($input: TestInputObject) { fieldWithObjectInput(input: $input) }"#;
|
||||
|
@ -421,7 +430,9 @@ fn variable_error_on_additional_field() {
|
|||
.into_iter()
|
||||
.collect();
|
||||
|
||||
let error = crate::execute_sync(query, None, &schema, &vars, &()).unwrap_err();
|
||||
let error = crate::execute(query, None, &schema, &vars, &())
|
||||
.await
|
||||
.unwrap_err();
|
||||
|
||||
assert_eq!(
|
||||
error,
|
||||
|
@ -432,8 +443,8 @@ fn variable_error_on_additional_field() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn allow_nullable_inputs_to_be_omitted() {
|
||||
#[tokio::test]
|
||||
async fn allow_nullable_inputs_to_be_omitted() {
|
||||
run_query(
|
||||
r#"{ fieldWithNullableStringInput }"#,
|
||||
|result: &Object<DefaultScalarValue>| {
|
||||
|
@ -442,11 +453,12 @@ fn allow_nullable_inputs_to_be_omitted() {
|
|||
Some(&Value::scalar(r#"None"#))
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn allow_nullable_inputs_to_be_omitted_in_variable() {
|
||||
#[tokio::test]
|
||||
async fn allow_nullable_inputs_to_be_omitted_in_variable() {
|
||||
run_query(
|
||||
r#"query q($value: String) { fieldWithNullableStringInput(input: $value) }"#,
|
||||
|result: &Object<DefaultScalarValue>| {
|
||||
|
@ -455,11 +467,12 @@ fn allow_nullable_inputs_to_be_omitted_in_variable() {
|
|||
Some(&Value::scalar(r#"None"#))
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn allow_nullable_inputs_to_be_explicitly_null() {
|
||||
#[tokio::test]
|
||||
async fn allow_nullable_inputs_to_be_explicitly_null() {
|
||||
run_query(
|
||||
r#"{ fieldWithNullableStringInput(input: null) }"#,
|
||||
|result: &Object<DefaultScalarValue>| {
|
||||
|
@ -468,11 +481,12 @@ fn allow_nullable_inputs_to_be_explicitly_null() {
|
|||
Some(&Value::scalar(r#"None"#))
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn allow_nullable_inputs_to_be_set_to_null_in_variable() {
|
||||
#[tokio::test]
|
||||
async fn allow_nullable_inputs_to_be_set_to_null_in_variable() {
|
||||
run_variable_query(
|
||||
r#"query q($value: String) { fieldWithNullableStringInput(input: $value) }"#,
|
||||
vec![("value".to_owned(), InputValue::null())]
|
||||
|
@ -484,11 +498,12 @@ fn allow_nullable_inputs_to_be_set_to_null_in_variable() {
|
|||
Some(&Value::scalar(r#"None"#))
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn allow_nullable_inputs_to_be_set_to_value_in_variable() {
|
||||
#[tokio::test]
|
||||
async fn allow_nullable_inputs_to_be_set_to_value_in_variable() {
|
||||
run_variable_query(
|
||||
r#"query q($value: String) { fieldWithNullableStringInput(input: $value) }"#,
|
||||
vec![("value".to_owned(), InputValue::scalar("a"))]
|
||||
|
@ -500,11 +515,12 @@ fn allow_nullable_inputs_to_be_set_to_value_in_variable() {
|
|||
Some(&Value::scalar(r#"Some("a")"#))
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn allow_nullable_inputs_to_be_set_to_value_directly() {
|
||||
#[tokio::test]
|
||||
async fn allow_nullable_inputs_to_be_set_to_value_directly() {
|
||||
run_query(
|
||||
r#"{ fieldWithNullableStringInput(input: "a") }"#,
|
||||
|result: &Object<DefaultScalarValue>| {
|
||||
|
@ -513,17 +529,20 @@ fn allow_nullable_inputs_to_be_set_to_value_directly() {
|
|||
Some(&Value::scalar(r#"Some("a")"#))
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn does_not_allow_non_nullable_input_to_be_omitted_in_variable() {
|
||||
#[tokio::test]
|
||||
async fn does_not_allow_non_nullable_input_to_be_omitted_in_variable() {
|
||||
let schema = RootNode::new(TestType, EmptyMutation::<()>::new());
|
||||
|
||||
let query = r#"query q($value: String!) { fieldWithNonNullableStringInput(input: $value) }"#;
|
||||
let vars = vec![].into_iter().collect();
|
||||
|
||||
let error = crate::execute_sync(query, None, &schema, &vars, &()).unwrap_err();
|
||||
let error = crate::execute(query, None, &schema, &vars, &())
|
||||
.await
|
||||
.unwrap_err();
|
||||
|
||||
assert_eq!(
|
||||
error,
|
||||
|
@ -534,8 +553,8 @@ fn does_not_allow_non_nullable_input_to_be_omitted_in_variable() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn does_not_allow_non_nullable_input_to_be_set_to_null_in_variable() {
|
||||
#[tokio::test]
|
||||
async fn does_not_allow_non_nullable_input_to_be_set_to_null_in_variable() {
|
||||
let schema = RootNode::new(TestType, EmptyMutation::<()>::new());
|
||||
|
||||
let query = r#"query q($value: String!) { fieldWithNonNullableStringInput(input: $value) }"#;
|
||||
|
@ -543,7 +562,9 @@ fn does_not_allow_non_nullable_input_to_be_set_to_null_in_variable() {
|
|||
.into_iter()
|
||||
.collect();
|
||||
|
||||
let error = crate::execute_sync(query, None, &schema, &vars, &()).unwrap_err();
|
||||
let error = crate::execute(query, None, &schema, &vars, &())
|
||||
.await
|
||||
.unwrap_err();
|
||||
|
||||
assert_eq!(
|
||||
error,
|
||||
|
@ -554,8 +575,8 @@ fn does_not_allow_non_nullable_input_to_be_set_to_null_in_variable() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn allow_non_nullable_inputs_to_be_set_to_value_in_variable() {
|
||||
#[tokio::test]
|
||||
async fn allow_non_nullable_inputs_to_be_set_to_value_in_variable() {
|
||||
run_variable_query(
|
||||
r#"query q($value: String!) { fieldWithNonNullableStringInput(input: $value) }"#,
|
||||
vec![("value".to_owned(), InputValue::scalar("a"))]
|
||||
|
@ -567,11 +588,12 @@ fn allow_non_nullable_inputs_to_be_set_to_value_in_variable() {
|
|||
Some(&Value::scalar(r#""a""#))
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn allow_non_nullable_inputs_to_be_set_to_value_directly() {
|
||||
#[tokio::test]
|
||||
async fn allow_non_nullable_inputs_to_be_set_to_value_directly() {
|
||||
run_query(
|
||||
r#"{ fieldWithNonNullableStringInput(input: "a") }"#,
|
||||
|result: &Object<DefaultScalarValue>| {
|
||||
|
@ -580,11 +602,12 @@ fn allow_non_nullable_inputs_to_be_set_to_value_directly() {
|
|||
Some(&Value::scalar(r#""a""#))
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn allow_lists_to_be_null() {
|
||||
#[tokio::test]
|
||||
async fn allow_lists_to_be_null() {
|
||||
run_variable_query(
|
||||
r#"query q($input: [String]) { list(input: $input) }"#,
|
||||
vec![("input".to_owned(), InputValue::null())]
|
||||
|
@ -596,11 +619,12 @@ fn allow_lists_to_be_null() {
|
|||
Some(&Value::scalar(r#"None"#))
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn allow_lists_to_contain_values() {
|
||||
#[tokio::test]
|
||||
async fn allow_lists_to_contain_values() {
|
||||
run_variable_query(
|
||||
r#"query q($input: [String]) { list(input: $input) }"#,
|
||||
vec![(
|
||||
|
@ -615,11 +639,12 @@ fn allow_lists_to_contain_values() {
|
|||
Some(&Value::scalar(r#"Some([Some("A")])"#))
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn allow_lists_to_contain_null() {
|
||||
#[tokio::test]
|
||||
async fn allow_lists_to_contain_null() {
|
||||
run_variable_query(
|
||||
r#"query q($input: [String]) { list(input: $input) }"#,
|
||||
vec![(
|
||||
|
@ -638,11 +663,12 @@ fn allow_lists_to_contain_null() {
|
|||
Some(&Value::scalar(r#"Some([Some("A"), None, Some("B")])"#))
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn does_not_allow_non_null_lists_to_be_null() {
|
||||
#[tokio::test]
|
||||
async fn does_not_allow_non_null_lists_to_be_null() {
|
||||
let schema = RootNode::new(TestType, EmptyMutation::<()>::new());
|
||||
|
||||
let query = r#"query q($input: [String]!) { nnList(input: $input) }"#;
|
||||
|
@ -650,7 +676,9 @@ fn does_not_allow_non_null_lists_to_be_null() {
|
|||
.into_iter()
|
||||
.collect();
|
||||
|
||||
let error = crate::execute_sync(query, None, &schema, &vars, &()).unwrap_err();
|
||||
let error = crate::execute(query, None, &schema, &vars, &())
|
||||
.await
|
||||
.unwrap_err();
|
||||
|
||||
assert_eq!(
|
||||
error,
|
||||
|
@ -661,8 +689,8 @@ fn does_not_allow_non_null_lists_to_be_null() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn allow_non_null_lists_to_contain_values() {
|
||||
#[tokio::test]
|
||||
async fn allow_non_null_lists_to_contain_values() {
|
||||
run_variable_query(
|
||||
r#"query q($input: [String]!) { nnList(input: $input) }"#,
|
||||
vec![(
|
||||
|
@ -677,10 +705,11 @@ fn allow_non_null_lists_to_contain_values() {
|
|||
Some(&Value::scalar(r#"[Some("A")]"#))
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
.await;
|
||||
}
|
||||
#[test]
|
||||
fn allow_non_null_lists_to_contain_null() {
|
||||
#[tokio::test]
|
||||
async fn allow_non_null_lists_to_contain_null() {
|
||||
run_variable_query(
|
||||
r#"query q($input: [String]!) { nnList(input: $input) }"#,
|
||||
vec![(
|
||||
|
@ -699,11 +728,12 @@ fn allow_non_null_lists_to_contain_null() {
|
|||
Some(&Value::scalar(r#"[Some("A"), None, Some("B")]"#))
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn allow_lists_of_non_null_to_be_null() {
|
||||
#[tokio::test]
|
||||
async fn allow_lists_of_non_null_to_be_null() {
|
||||
run_variable_query(
|
||||
r#"query q($input: [String!]) { listNn(input: $input) }"#,
|
||||
vec![("input".to_owned(), InputValue::null())]
|
||||
|
@ -715,11 +745,12 @@ fn allow_lists_of_non_null_to_be_null() {
|
|||
Some(&Value::scalar(r#"None"#))
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn allow_lists_of_non_null_to_contain_values() {
|
||||
#[tokio::test]
|
||||
async fn allow_lists_of_non_null_to_contain_values() {
|
||||
run_variable_query(
|
||||
r#"query q($input: [String!]) { listNn(input: $input) }"#,
|
||||
vec![(
|
||||
|
@ -734,11 +765,12 @@ fn allow_lists_of_non_null_to_contain_values() {
|
|||
Some(&Value::scalar(r#"Some(["A"])"#))
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn does_not_allow_lists_of_non_null_to_contain_null() {
|
||||
#[tokio::test]
|
||||
async fn does_not_allow_lists_of_non_null_to_contain_null() {
|
||||
let schema = RootNode::new(TestType, EmptyMutation::<()>::new());
|
||||
|
||||
let query = r#"query q($input: [String!]) { listNn(input: $input) }"#;
|
||||
|
@ -753,7 +785,9 @@ fn does_not_allow_lists_of_non_null_to_contain_null() {
|
|||
.into_iter()
|
||||
.collect();
|
||||
|
||||
let error = crate::execute_sync(query, None, &schema, &vars, &()).unwrap_err();
|
||||
let error = crate::execute(query, None, &schema, &vars, &())
|
||||
.await
|
||||
.unwrap_err();
|
||||
|
||||
assert_eq!(
|
||||
error,
|
||||
|
@ -764,8 +798,8 @@ fn does_not_allow_lists_of_non_null_to_contain_null() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn does_not_allow_non_null_lists_of_non_null_to_contain_null() {
|
||||
#[tokio::test]
|
||||
async fn does_not_allow_non_null_lists_of_non_null_to_contain_null() {
|
||||
let schema = RootNode::new(TestType, EmptyMutation::<()>::new());
|
||||
|
||||
let query = r#"query q($input: [String!]!) { nnListNn(input: $input) }"#;
|
||||
|
@ -780,7 +814,9 @@ fn does_not_allow_non_null_lists_of_non_null_to_contain_null() {
|
|||
.into_iter()
|
||||
.collect();
|
||||
|
||||
let error = crate::execute_sync(query, None, &schema, &vars, &()).unwrap_err();
|
||||
let error = crate::execute(query, None, &schema, &vars, &())
|
||||
.await
|
||||
.unwrap_err();
|
||||
|
||||
assert_eq!(
|
||||
error,
|
||||
|
@ -791,8 +827,8 @@ fn does_not_allow_non_null_lists_of_non_null_to_contain_null() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn does_not_allow_non_null_lists_of_non_null_to_be_null() {
|
||||
#[tokio::test]
|
||||
async fn does_not_allow_non_null_lists_of_non_null_to_be_null() {
|
||||
let schema = RootNode::new(TestType, EmptyMutation::<()>::new());
|
||||
|
||||
let query = r#"query q($input: [String!]!) { nnListNn(input: $input) }"#;
|
||||
|
@ -800,7 +836,9 @@ fn does_not_allow_non_null_lists_of_non_null_to_be_null() {
|
|||
.into_iter()
|
||||
.collect();
|
||||
|
||||
let error = crate::execute_sync(query, None, &schema, &vars, &()).unwrap_err();
|
||||
let error = crate::execute(query, None, &schema, &vars, &())
|
||||
.await
|
||||
.unwrap_err();
|
||||
|
||||
assert_eq!(
|
||||
error,
|
||||
|
@ -811,8 +849,8 @@ fn does_not_allow_non_null_lists_of_non_null_to_be_null() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn allow_non_null_lists_of_non_null_to_contain_values() {
|
||||
#[tokio::test]
|
||||
async fn allow_non_null_lists_of_non_null_to_contain_values() {
|
||||
run_variable_query(
|
||||
r#"query q($input: [String!]!) { nnListNn(input: $input) }"#,
|
||||
vec![(
|
||||
|
@ -827,21 +865,23 @@ fn allow_non_null_lists_of_non_null_to_contain_values() {
|
|||
Some(&Value::scalar(r#"["A"]"#))
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn default_argument_when_not_provided() {
|
||||
#[tokio::test]
|
||||
async fn default_argument_when_not_provided() {
|
||||
run_query(r#"{ fieldWithDefaultArgumentValue }"#, |result| {
|
||||
assert_eq!(
|
||||
result.get_field_value("fieldWithDefaultArgumentValue"),
|
||||
Some(&Value::scalar(r#""Hello World""#))
|
||||
);
|
||||
});
|
||||
})
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn default_argument_when_nullable_variable_not_provided() {
|
||||
#[tokio::test]
|
||||
async fn default_argument_when_nullable_variable_not_provided() {
|
||||
run_query(
|
||||
r#"query q($input: String) { fieldWithDefaultArgumentValue(input: $input) }"#,
|
||||
|result| {
|
||||
|
@ -850,11 +890,12 @@ fn default_argument_when_nullable_variable_not_provided() {
|
|||
Some(&Value::scalar(r#""Hello World""#))
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn default_argument_when_nullable_variable_set_to_null() {
|
||||
#[tokio::test]
|
||||
async fn default_argument_when_nullable_variable_set_to_null() {
|
||||
run_variable_query(
|
||||
r#"query q($input: String) { fieldWithDefaultArgumentValue(input: $input) }"#,
|
||||
vec![("input".to_owned(), InputValue::null())]
|
||||
|
@ -866,28 +907,31 @@ fn default_argument_when_nullable_variable_set_to_null() {
|
|||
Some(&Value::scalar(r#""Hello World""#))
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nullable_input_object_arguments_successful_without_variables() {
|
||||
#[tokio::test]
|
||||
async fn nullable_input_object_arguments_successful_without_variables() {
|
||||
run_query(r#"{ exampleInput(arg: {a: "abc", b: 123}) }"#, |result| {
|
||||
assert_eq!(
|
||||
result.get_field_value("exampleInput"),
|
||||
Some(&Value::scalar(r#"a: Some("abc"), b: 123"#))
|
||||
);
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
run_query(r#"{ exampleInput(arg: {a: null, b: 1}) }"#, |result| {
|
||||
assert_eq!(
|
||||
result.get_field_value("exampleInput"),
|
||||
Some(&Value::scalar(r#"a: None, b: 1"#))
|
||||
);
|
||||
});
|
||||
})
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nullable_input_object_arguments_successful_with_variables() {
|
||||
#[tokio::test]
|
||||
async fn nullable_input_object_arguments_successful_with_variables() {
|
||||
run_variable_query(
|
||||
r#"query q($var: Int!) { exampleInput(arg: {b: $var}) }"#,
|
||||
vec![("var".to_owned(), InputValue::scalar(123))]
|
||||
|
@ -899,7 +943,8 @@ fn nullable_input_object_arguments_successful_with_variables() {
|
|||
Some(&Value::scalar(r#"a: None, b: 123"#))
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
.await;
|
||||
|
||||
run_variable_query(
|
||||
r#"query q($var: String) { exampleInput(arg: {a: $var, b: 1}) }"#,
|
||||
|
@ -912,7 +957,8 @@ fn nullable_input_object_arguments_successful_with_variables() {
|
|||
Some(&Value::scalar(r#"a: None, b: 1"#))
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
.await;
|
||||
|
||||
run_variable_query(
|
||||
r#"query q($var: String) { exampleInput(arg: {a: $var, b: 1}) }"#,
|
||||
|
@ -923,17 +969,20 @@ fn nullable_input_object_arguments_successful_with_variables() {
|
|||
Some(&Value::scalar(r#"a: None, b: 1"#))
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn does_not_allow_missing_required_field() {
|
||||
#[tokio::test]
|
||||
async fn does_not_allow_missing_required_field() {
|
||||
let schema = RootNode::new(TestType, EmptyMutation::<()>::new());
|
||||
|
||||
let query = r#"{ exampleInput(arg: {a: "abc"}) }"#;
|
||||
let vars = vec![].into_iter().collect();
|
||||
|
||||
let error = crate::execute_sync(query, None, &schema, &vars, &()).unwrap_err();
|
||||
let error = crate::execute(query, None, &schema, &vars, &())
|
||||
.await
|
||||
.unwrap_err();
|
||||
|
||||
assert_eq!(
|
||||
error,
|
||||
|
@ -944,14 +993,16 @@ fn does_not_allow_missing_required_field() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn does_not_allow_null_in_required_field() {
|
||||
#[tokio::test]
|
||||
async fn does_not_allow_null_in_required_field() {
|
||||
let schema = RootNode::new(TestType, EmptyMutation::<()>::new());
|
||||
|
||||
let query = r#"{ exampleInput(arg: {a: "abc", b: null}) }"#;
|
||||
let vars = vec![].into_iter().collect();
|
||||
|
||||
let error = crate::execute_sync(query, None, &schema, &vars, &()).unwrap_err();
|
||||
let error = crate::execute(query, None, &schema, &vars, &())
|
||||
.await
|
||||
.unwrap_err();
|
||||
|
||||
assert_eq!(
|
||||
error,
|
||||
|
@ -962,14 +1013,16 @@ fn does_not_allow_null_in_required_field() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn does_not_allow_missing_variable_for_required_field() {
|
||||
#[tokio::test]
|
||||
async fn does_not_allow_missing_variable_for_required_field() {
|
||||
let schema = RootNode::new(TestType, EmptyMutation::<()>::new());
|
||||
|
||||
let query = r#"query q($var: Int!) { exampleInput(arg: {b: $var}) }"#;
|
||||
let vars = vec![].into_iter().collect();
|
||||
|
||||
let error = crate::execute_sync(query, None, &schema, &vars, &()).unwrap_err();
|
||||
let error = crate::execute(query, None, &schema, &vars, &())
|
||||
.await
|
||||
.unwrap_err();
|
||||
|
||||
assert_eq!(
|
||||
error,
|
||||
|
@ -980,8 +1033,8 @@ fn does_not_allow_missing_variable_for_required_field() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn does_not_allow_null_variable_for_required_field() {
|
||||
#[tokio::test]
|
||||
async fn does_not_allow_null_variable_for_required_field() {
|
||||
let schema = RootNode::new(TestType, EmptyMutation::<()>::new());
|
||||
|
||||
let query = r#"query q($var: Int!) { exampleInput(arg: {b: $var}) }"#;
|
||||
|
@ -989,7 +1042,9 @@ fn does_not_allow_null_variable_for_required_field() {
|
|||
.into_iter()
|
||||
.collect();
|
||||
|
||||
let error = crate::execute_sync(query, None, &schema, &vars, &()).unwrap_err();
|
||||
let error = crate::execute(query, None, &schema, &vars, &())
|
||||
.await
|
||||
.unwrap_err();
|
||||
|
||||
assert_eq!(
|
||||
error,
|
||||
|
@ -1000,14 +1055,15 @@ fn does_not_allow_null_variable_for_required_field() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn input_object_with_default_values() {
|
||||
#[tokio::test]
|
||||
async fn input_object_with_default_values() {
|
||||
run_query(r#"{ inputWithDefaults(arg: {a: 1}) }"#, |result| {
|
||||
assert_eq!(
|
||||
result.get_field_value("inputWithDefaults"),
|
||||
Some(&Value::scalar(r#"a: 1"#))
|
||||
);
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
run_variable_query(
|
||||
r#"query q($var: Int!) { inputWithDefaults(arg: {a: $var}) }"#,
|
||||
|
@ -1020,7 +1076,8 @@ fn input_object_with_default_values() {
|
|||
Some(&Value::scalar(r#"a: 1"#))
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
.await;
|
||||
|
||||
run_variable_query(
|
||||
r#"query q($var: Int = 1) { inputWithDefaults(arg: {a: $var}) }"#,
|
||||
|
@ -1031,7 +1088,8 @@ fn input_object_with_default_values() {
|
|||
Some(&Value::scalar(r#"a: 1"#))
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
.await;
|
||||
|
||||
run_variable_query(
|
||||
r#"query q($var: Int = 1) { inputWithDefaults(arg: {a: $var}) }"#,
|
||||
|
@ -1044,14 +1102,15 @@ fn input_object_with_default_values() {
|
|||
Some(&Value::scalar(r#"a: 2"#))
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
mod integers {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn positive_and_negative_should_work() {
|
||||
#[tokio::test]
|
||||
async fn positive_and_negative_should_work() {
|
||||
run_variable_query(
|
||||
r#"query q($var: Int!) { integerInput(value: $var) }"#,
|
||||
vec![("var".to_owned(), InputValue::scalar(1))]
|
||||
|
@ -1063,7 +1122,8 @@ mod integers {
|
|||
Some(&Value::scalar(r#"value: 1"#))
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
.await;
|
||||
|
||||
run_variable_query(
|
||||
r#"query q($var: Int!) { integerInput(value: $var) }"#,
|
||||
|
@ -1076,11 +1136,12 @@ mod integers {
|
|||
Some(&Value::scalar(r#"value: -1"#))
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn does_not_coerce_from_float() {
|
||||
#[tokio::test]
|
||||
async fn does_not_coerce_from_float() {
|
||||
let schema = RootNode::new(TestType, EmptyMutation::<()>::new());
|
||||
|
||||
let query = r#"query q($var: Int!) { integerInput(value: $var) }"#;
|
||||
|
@ -1088,7 +1149,9 @@ mod integers {
|
|||
.into_iter()
|
||||
.collect();
|
||||
|
||||
let error = crate::execute_sync(query, None, &schema, &vars, &()).unwrap_err();
|
||||
let error = crate::execute(query, None, &schema, &vars, &())
|
||||
.await
|
||||
.unwrap_err();
|
||||
|
||||
assert_eq!(
|
||||
error,
|
||||
|
@ -1099,8 +1162,8 @@ mod integers {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn does_not_coerce_from_string() {
|
||||
#[tokio::test]
|
||||
async fn does_not_coerce_from_string() {
|
||||
let schema = RootNode::new(TestType, EmptyMutation::<()>::new());
|
||||
|
||||
let query = r#"query q($var: Int!) { integerInput(value: $var) }"#;
|
||||
|
@ -1108,7 +1171,9 @@ mod integers {
|
|||
.into_iter()
|
||||
.collect();
|
||||
|
||||
let error = crate::execute_sync(query, None, &schema, &vars, &()).unwrap_err();
|
||||
let error = crate::execute(query, None, &schema, &vars, &())
|
||||
.await
|
||||
.unwrap_err();
|
||||
|
||||
assert_eq!(
|
||||
error,
|
||||
|
@ -1123,8 +1188,8 @@ mod integers {
|
|||
mod floats {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn float_values_should_work() {
|
||||
#[tokio::test]
|
||||
async fn float_values_should_work() {
|
||||
run_variable_query(
|
||||
r#"query q($var: Float!) { floatInput(value: $var) }"#,
|
||||
vec![("var".to_owned(), InputValue::scalar(10.0))]
|
||||
|
@ -1136,11 +1201,12 @@ mod floats {
|
|||
Some(&Value::scalar(r#"value: 10"#))
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn coercion_from_integers_should_work() {
|
||||
#[tokio::test]
|
||||
async fn coercion_from_integers_should_work() {
|
||||
run_variable_query(
|
||||
r#"query q($var: Float!) { floatInput(value: $var) }"#,
|
||||
vec![("var".to_owned(), InputValue::scalar(-1))]
|
||||
|
@ -1152,11 +1218,12 @@ mod floats {
|
|||
Some(&Value::scalar(r#"value: -1"#))
|
||||
);
|
||||
},
|
||||
);
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn does_not_coerce_from_string() {
|
||||
#[tokio::test]
|
||||
async fn does_not_coerce_from_string() {
|
||||
let schema = RootNode::new(TestType, EmptyMutation::<()>::new());
|
||||
|
||||
let query = r#"query q($var: Float!) { floatInput(value: $var) }"#;
|
||||
|
@ -1164,7 +1231,9 @@ mod floats {
|
|||
.into_iter()
|
||||
.collect();
|
||||
|
||||
let error = crate::execute_sync(query, None, &schema, &vars, &()).unwrap_err();
|
||||
let error = crate::execute(query, None, &schema, &vars, &())
|
||||
.await
|
||||
.unwrap_err();
|
||||
|
||||
assert_eq!(
|
||||
error,
|
||||
|
|
Loading…
Reference in a new issue