From bd47d4f7db6ef064f6322b15bfac1fcde5cb52b6 Mon Sep 17 00:00:00 2001 From: Piotr Findeisen Date: Sun, 24 Nov 2024 23:47:53 +0100 Subject: [PATCH] Remove redundant assert_starts_with test helper (#13542) Replace with usage of `DataFusionError::strip_backtrace`. --- .../physical-plan/src/execution_plan.rs | 35 +++++++------------ 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/datafusion/physical-plan/src/execution_plan.rs b/datafusion/physical-plan/src/execution_plan.rs index 7220e7594ea6..4b91cfff062b 100644 --- a/datafusion/physical-plan/src/execution_plan.rs +++ b/datafusion/physical-plan/src/execution_plan.rs @@ -1098,9 +1098,9 @@ mod tests { &vec![0], ); assert!(result.is_err()); - assert_starts_with( - result.err().unwrap().message().as_ref(), - "Invalid batch column at '0' has null but schema specifies non-nullable", + assert_eq!( + result.err().unwrap().strip_backtrace(), + "Execution error: Invalid batch column at '0' has null but schema specifies non-nullable", ); Ok(()) } @@ -1123,9 +1123,9 @@ mod tests { &vec![0], ); assert!(result.is_err()); - assert_starts_with( - result.err().unwrap().message().as_ref(), - "Invalid batch column at '0' has null but schema specifies non-nullable", + assert_eq!( + result.err().unwrap().strip_backtrace(), + "Execution error: Invalid batch column at '0' has null but schema specifies non-nullable", ); Ok(()) } @@ -1147,9 +1147,9 @@ mod tests { &vec![0], ); assert!(result.is_err()); - assert_starts_with( - result.err().unwrap().message().as_ref(), - "Invalid batch column at '0' has null but schema specifies non-nullable", + assert_eq!( + result.err().unwrap().strip_backtrace(), + "Execution error: Invalid batch column at '0' has null but schema specifies non-nullable", ); Ok(()) } @@ -1190,21 +1190,10 @@ mod tests { &vec![0], ); assert!(result.is_err()); - assert_starts_with( - result.err().unwrap().message().as_ref(), - "Invalid batch column at '0' has null but schema specifies non-nullable", + assert_eq!( + result.err().unwrap().strip_backtrace(), + "Execution error: Invalid batch column at '0' has null but schema specifies non-nullable", ); Ok(()) } - - fn assert_starts_with(actual: impl AsRef, expected_prefix: impl AsRef) { - let actual = actual.as_ref(); - let expected_prefix = expected_prefix.as_ref(); - assert!( - actual.starts_with(expected_prefix), - "Expected '{}' to start with '{}'", - actual, - expected_prefix - ); - } }