tests for steel in post request is fixed with all the errors found in the codebase
This commit is contained in:
@@ -149,9 +149,27 @@ pub async fn post_table_data(
|
||||
let expected_value = script_output.pop()
|
||||
.ok_or_else(|| Status::internal("Script returned no values"))?;
|
||||
|
||||
if user_value != &expected_value {
|
||||
// FIX: Compare as Decimal numbers, not strings!
|
||||
// Parse the user's value into a Decimal
|
||||
let user_decimal = Decimal::from_str(user_value).map_err(|_| {
|
||||
Status::invalid_argument(format!(
|
||||
"Invalid decimal format provided for column '{}': {}",
|
||||
target_column, user_value
|
||||
))
|
||||
})?;
|
||||
|
||||
// Parse the script's calculated value into a Decimal
|
||||
let expected_decimal = Decimal::from_str(&expected_value).map_err(|_| {
|
||||
Status::internal(format!(
|
||||
"Script for column '{}' produced an invalid decimal format: {}",
|
||||
target_column, expected_value
|
||||
))
|
||||
})?;
|
||||
|
||||
// Now compare the actual numbers - this correctly sees that 76.5 == 76.50
|
||||
if user_decimal != expected_decimal {
|
||||
return Err(Status::invalid_argument(format!(
|
||||
"Validation failed for column '{}': Expected '{}', Got '{}'",
|
||||
"Validation failed for column '{}': Script calculated '{}', but user provided '{}'",
|
||||
target_column, expected_value, user_value
|
||||
)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user