From 63544aab5b1180bd92bd396e683cef50653211ba Mon Sep 17 00:00:00 2001 From: Sunli Date: Thu, 4 Nov 2021 14:54:26 +0800 Subject: [PATCH] Fix tests --- src/error.rs | 1 + tests/federation.rs | 1 + tests/field_features.rs | 3 +++ tests/guard.rs | 12 ++++++++++++ tests/input_validators.rs | 39 +++++++++++++++++++++++++++++++++++++++ tests/input_value.rs | 1 + tests/list.rs | 1 + tests/result.rs | 8 ++++++++ tests/subscription.rs | 2 ++ 9 files changed, 68 insertions(+) diff --git a/src/error.rs b/src/error.rs index 5bdb3401..1bcacc9e 100644 --- a/src/error.rs +++ b/src/error.rs @@ -177,6 +177,7 @@ pub struct Error { /// The error message. pub message: String, /// The debug error message. + #[serde(skip)] pub debug_message: Option, /// Extensions to the error. #[serde(skip_serializing_if = "error_extensions_is_empty")] diff --git a/tests/federation.rs b/tests/federation.rs index 36279fa1..acf46d4e 100644 --- a/tests/federation.rs +++ b/tests/federation.rs @@ -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 diff --git a/tests/field_features.rs b/tests/field_features.rs index 8bb3d13e..0b85ae19 100644 --- a/tests/field_features.rs +++ b/tests/field_features.rs @@ -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 diff --git a/tests/guard.rs b/tests/guard.rs index bd2b88b6..89396ac2 100644 --- a/tests/guard.rs +++ b/tests/guard.rs @@ -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, diff --git a/tests/input_validators.rs b/tests/input_validators.rs index 4807903e..139d210c 100644 --- a/tests/input_validators.rs +++ b/tests/input_validators.rs @@ -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 diff --git a/tests/input_value.rs b/tests/input_value.rs index aa3e04bb..74560091 100644 --- a/tests/input_value.rs +++ b/tests/input_value.rs @@ -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, diff --git a/tests/list.rs b/tests/list.rs index b48c5c16..da13ee4f 100644 --- a/tests/list.rs +++ b/tests/list.rs @@ -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, diff --git a/tests/result.rs b/tests/result.rs index 71616e91..aac660db 100644 --- a/tests/result.rs +++ b/tests/result.rs @@ -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, diff --git a/tests/subscription.rs b/tests/subscription.rs index 7d43c3f1..9763881e 100644 --- a/tests/subscription.rs +++ b/tests/subscription.rs @@ -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