test(errors): add unit test for 1364 schema mismatch error
Covers the fix from 308a7f2 — verifies that MariaDB error 1364
is classified as database_schema and the field name is extracted
into a readable message.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -41,6 +41,22 @@ def test_null_error_handling():
|
|||||||
else:
|
else:
|
||||||
print("❌ Null error check FAILED.")
|
print("❌ Null error check FAILED.")
|
||||||
|
|
||||||
|
def test_1364_schema_mismatch():
|
||||||
|
print("\n--- Testing 1364 Schema Mismatch ---")
|
||||||
|
raw = "(MySQLdb.OperationalError) (1364, \"Field 'account' doesn't have a default value\")"
|
||||||
|
formatted = format_db_error(raw)
|
||||||
|
print(f"Raw: {raw}")
|
||||||
|
print(f"Formatted: {formatted}")
|
||||||
|
|
||||||
|
if (formatted.category == "database_schema"
|
||||||
|
and formatted.code == 1364
|
||||||
|
and "account" in formatted.message
|
||||||
|
and "NOT NULL" in formatted.message):
|
||||||
|
print("✅ 1364 schema mismatch handled correctly.")
|
||||||
|
else:
|
||||||
|
print("❌ 1364 schema mismatch check FAILED.")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test_error_formatting()
|
test_error_formatting()
|
||||||
test_null_error_handling()
|
test_null_error_handling()
|
||||||
|
test_1364_schema_mismatch()
|
||||||
|
|||||||
Reference in New Issue
Block a user