Fix tests

This commit is contained in:
Sunli 2021-11-04 14:54:26 +08:00
parent 755a7f92df
commit 63544aab5b
9 changed files with 68 additions and 0 deletions

View File

@ -177,6 +177,7 @@ pub struct Error {
/// The error message.
pub message: String,
/// The debug error message.
#[serde(skip)]
pub debug_message: Option<String>,
/// Extensions to the error.
#[serde(skip_serializing_if = "error_extensions_is_empty")]

View File

@ -242,6 +242,7 @@ pub async fn test_find_entity_with_context() {
schema.execute(query).await.into_result().unwrap_err(),
vec![ServerError {
message: "Not found".to_string(),
debug_message: None,
locations: vec![Pos {
line: 2,
column: 13

View File

@ -85,6 +85,7 @@ pub async fn test_field_features() {
vec![ServerError {
message: r#"Unknown field "valueAbc" on type "QueryRoot". Did you mean "value"?"#
.to_owned(),
debug_message: None,
locations: vec![Pos { column: 3, line: 1 }],
path: Vec::new(),
extensions: None,
@ -113,6 +114,7 @@ pub async fn test_field_features() {
vec![ServerError {
message: r#"Unknown field "valueAbc" on type "MyObj". Did you mean "value"?"#
.to_owned(),
debug_message: None,
locations: vec![Pos { column: 9, line: 1 }],
path: Vec::new(),
extensions: None,
@ -148,6 +150,7 @@ pub async fn test_field_features() {
.errors,
vec![ServerError {
message: r#"Unknown field "valuesAbc" on type "SubscriptionRoot". Did you mean "values", "valuesBson"?"#.to_owned(),
debug_message: None,
locations: vec![Pos {
column: 16,
line: 1

View File

@ -99,6 +99,7 @@ pub async fn test_guard_simple_rule() {
.unwrap_err(),
vec![ServerError {
message: "Forbidden".to_string(),
debug_message: None,
locations: vec![Pos { line: 1, column: 3 }],
path: vec![PathSegment::Field("value".to_owned())],
extensions: None,
@ -127,6 +128,7 @@ pub async fn test_guard_simple_rule() {
.errors,
vec![ServerError {
message: "Forbidden".to_string(),
debug_message: None,
locations: vec![Pos {
line: 1,
column: 16
@ -176,6 +178,7 @@ pub async fn test_guard_and_operator() {
.unwrap_err(),
vec![ServerError {
message: "Forbidden".to_string(),
debug_message: None,
locations: vec![Pos { line: 1, column: 3 }],
path: vec![PathSegment::Field("value".to_owned())],
extensions: None,
@ -195,6 +198,7 @@ pub async fn test_guard_and_operator() {
.unwrap_err(),
vec![ServerError {
message: "Forbidden".to_string(),
debug_message: None,
locations: vec![Pos { line: 1, column: 3 }],
path: vec![PathSegment::Field("value".to_owned())],
extensions: None,
@ -214,6 +218,7 @@ pub async fn test_guard_and_operator() {
.unwrap_err(),
vec![ServerError {
message: "Forbidden".to_string(),
debug_message: None,
locations: vec![Pos { line: 1, column: 3 }],
path: vec![PathSegment::Field("value".to_owned())],
extensions: None,
@ -283,6 +288,7 @@ pub async fn test_guard_or_operator() {
.unwrap_err(),
vec![ServerError {
message: "Forbidden".to_string(),
debug_message: None,
locations: vec![Pos { line: 1, column: 3 }],
path: vec![PathSegment::Field("value".to_owned())],
extensions: None,
@ -332,6 +338,7 @@ pub async fn test_guard_chain_operator() {
.unwrap_err(),
vec![ServerError {
message: "Forbidden".to_string(),
debug_message: None,
locations: vec![Pos { line: 1, column: 3 }],
path: vec![PathSegment::Field("value".to_owned())],
extensions: None,
@ -352,6 +359,7 @@ pub async fn test_guard_chain_operator() {
.unwrap_err(),
vec![ServerError {
message: "Forbidden".to_string(),
debug_message: None,
locations: vec![Pos { line: 1, column: 3 }],
path: vec![PathSegment::Field("value".to_owned())],
extensions: None,
@ -372,6 +380,7 @@ pub async fn test_guard_chain_operator() {
.unwrap_err(),
vec![ServerError {
message: "Forbidden".to_string(),
debug_message: None,
locations: vec![Pos { line: 1, column: 3 }],
path: vec![PathSegment::Field("value".to_owned())],
extensions: None,
@ -392,6 +401,7 @@ pub async fn test_guard_chain_operator() {
.unwrap_err(),
vec![ServerError {
message: "Forbidden".to_string(),
debug_message: None,
locations: vec![Pos { line: 1, column: 3 }],
path: vec![PathSegment::Field("value".to_owned())],
extensions: None,
@ -483,6 +493,7 @@ pub async fn test_guard_race_operator() {
.unwrap_err(),
vec![ServerError {
message: "Forbidden".to_string(),
debug_message: None,
locations: vec![Pos { line: 1, column: 3 }],
path: vec![PathSegment::Field("value".to_owned())],
extensions: None,
@ -538,6 +549,7 @@ pub async fn test_guard_use_params() {
.unwrap_err(),
vec![ServerError {
message: "Forbidden".to_string(),
debug_message: None,
locations: vec![Pos { line: 1, column: 3 }],
path: vec![PathSegment::Field("get".to_owned())],
extensions: None,

View File

@ -67,6 +67,7 @@ pub async fn test_input_validator_string_min_length() {
.expect_err(&should_fail_msg),
vec![ServerError {
message: field_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 17
@ -84,6 +85,7 @@ pub async fn test_input_validator_string_min_length() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: object_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 14
@ -177,6 +179,7 @@ pub async fn test_input_validator_string_max_length() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: field_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 17
@ -194,6 +197,7 @@ pub async fn test_input_validator_string_max_length() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: object_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 14
@ -286,6 +290,7 @@ pub async fn test_input_validator_chars_min_length() {
.expect_err(&should_fail_msg),
vec![ServerError {
message: field_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 17
@ -303,6 +308,7 @@ pub async fn test_input_validator_chars_min_length() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: object_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 14
@ -397,6 +403,7 @@ pub async fn test_input_validator_chars_max_length() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: field_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 17
@ -414,6 +421,7 @@ pub async fn test_input_validator_chars_max_length() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: object_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 14
@ -534,6 +542,7 @@ pub async fn test_input_validator_string_email() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: field_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 17
@ -552,6 +561,7 @@ pub async fn test_input_validator_string_email() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: object_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 14
@ -682,6 +692,7 @@ pub async fn test_input_validator_string_mac() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: field_error_msg.clone(),
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 17
@ -700,6 +711,7 @@ pub async fn test_input_validator_string_mac() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: object_error_msg.clone(),
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 14
@ -717,6 +729,7 @@ pub async fn test_input_validator_string_mac() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: field_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 17
@ -735,6 +748,7 @@ pub async fn test_input_validator_string_mac() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: object_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 14
@ -792,6 +806,7 @@ pub async fn test_input_validator_string_mac() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: field_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 17
@ -810,6 +825,7 @@ pub async fn test_input_validator_string_mac() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: object_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 14
@ -851,6 +867,7 @@ pub async fn test_input_validator_string_mac() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: field_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 17
@ -869,6 +886,7 @@ pub async fn test_input_validator_string_mac() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: object_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 14
@ -929,6 +947,7 @@ pub async fn test_input_validator_int_range() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: field_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 17
@ -946,6 +965,7 @@ pub async fn test_input_validator_int_range() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: object_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 14
@ -1034,6 +1054,7 @@ pub async fn test_input_validator_int_less_than() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: field_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 17
@ -1051,6 +1072,7 @@ pub async fn test_input_validator_int_less_than() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: object_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 14
@ -1141,6 +1163,7 @@ pub async fn test_input_validator_int_greater_than() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: field_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 17
@ -1158,6 +1181,7 @@ pub async fn test_input_validator_int_greater_than() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: object_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 14
@ -1241,6 +1265,7 @@ pub async fn test_input_validator_int_nonzero() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: field_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 17
@ -1258,6 +1283,7 @@ pub async fn test_input_validator_int_nonzero() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: object_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 14
@ -1345,6 +1371,7 @@ pub async fn test_input_validator_int_equal() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: field_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 17
@ -1362,6 +1389,7 @@ pub async fn test_input_validator_int_equal() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: object_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 14
@ -1461,6 +1489,7 @@ pub async fn test_input_validator_list_max_length() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: field_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 17
@ -1478,6 +1507,7 @@ pub async fn test_input_validator_list_max_length() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: object_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 14
@ -1577,6 +1607,7 @@ pub async fn test_input_validator_list_min_length() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: field_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 17
@ -1594,6 +1625,7 @@ pub async fn test_input_validator_list_min_length() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: object_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 14
@ -1701,6 +1733,7 @@ pub async fn test_input_validator_operator_or() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: field_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 17
@ -1718,6 +1751,7 @@ pub async fn test_input_validator_operator_or() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: object_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 14
@ -1818,6 +1852,7 @@ pub async fn test_input_validator_operator_and() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: field_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 17
@ -1835,6 +1870,7 @@ pub async fn test_input_validator_operator_and() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: object_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 14
@ -1938,6 +1974,7 @@ pub async fn test_input_validator_variable() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: field_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 37
@ -1955,6 +1992,7 @@ pub async fn test_input_validator_variable() {
.expect_err(&should_fail_msg[..]),
vec![ServerError {
message: object_error_msg,
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 34
@ -2041,6 +2079,7 @@ pub async fn test_custom_input_validator_with_extensions() {
.expect_err(should_fail_msg),
vec![ServerError {
message: field_error_msg.into(),
debug_message: None,
locations: vec!(Pos {
line: 1,
column: 17

View File

@ -18,6 +18,7 @@ pub async fn test_input_value_custom_error() {
vec![ServerError {
message: "Failed to parse \"Int\": Only integers from -128 to 127 are accepted."
.to_owned(),
debug_message: None,
locations: vec![Pos {
line: 1,
column: 14,

View File

@ -167,6 +167,7 @@ pub async fn test_array_type() {
vec![ServerError {
message: r#"Failed to parse "[Int!]": Expected input type "[Int; 6]", found [Int; 5]."#
.to_owned(),
debug_message: None,
locations: vec![Pos {
line: 1,
column: 22,

View File

@ -34,12 +34,14 @@ pub async fn test_fieldresult() {
errors: vec![
ServerError {
message: "TestError".to_string(),
debug_message: None,
locations: vec![Pos { line: 1, column: 3 }],
path: vec![PathSegment::Field("error1".to_owned())],
extensions: None,
},
ServerError {
message: "TestError".to_string(),
debug_message: None,
locations: vec![Pos {
line: 1,
column: 19,
@ -60,6 +62,7 @@ pub async fn test_fieldresult() {
.unwrap_err(),
vec![ServerError {
message: "TestError".to_string(),
debug_message: None,
locations: vec![Pos { line: 1, column: 3 }],
path: vec![PathSegment::Field("optError".to_owned())],
extensions: None,
@ -74,6 +77,7 @@ pub async fn test_fieldresult() {
.unwrap_err(),
vec![ServerError {
message: "TestError".to_string(),
debug_message: None,
locations: vec![Pos { line: 1, column: 3 }],
path: vec![
PathSegment::Field("vecError".to_owned()),
@ -188,6 +192,7 @@ pub async fn test_error_propagation() {
cache_control: Default::default(),
errors: vec![ServerError {
message: "myerror".to_string(),
debug_message: None,
locations: vec![Pos {
line: 1,
column: 20,
@ -215,6 +220,7 @@ pub async fn test_error_propagation() {
cache_control: Default::default(),
errors: vec![ServerError {
message: "myerror".to_string(),
debug_message: None,
locations: vec![Pos {
line: 1,
column: 23,
@ -238,6 +244,7 @@ pub async fn test_error_propagation() {
cache_control: Default::default(),
errors: vec![ServerError {
message: "myerror".to_string(),
debug_message: None,
locations: vec![Pos {
line: 1,
column: 23,
@ -267,6 +274,7 @@ pub async fn test_error_propagation() {
cache_control: Default::default(),
errors: vec![ServerError {
message: "myerror".to_string(),
debug_message: None,
locations: vec![Pos {
line: 1,
column: 23,

View File

@ -345,6 +345,7 @@ pub async fn test_subscription_error() {
stream.next().await,
Some(Err(vec![ServerError {
message: "TestError".to_string(),
debug_message: None,
locations: vec![Pos {
line: 1,
column: 25
@ -390,6 +391,7 @@ pub async fn test_subscription_fieldresult() {
cache_control: Default::default(),
errors: vec![ServerError {
message: "StreamErr".to_string(),
debug_message: None,
locations: vec![Pos {
line: 1,
column: 16