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:
Scott Idem
2026-03-17 19:08:48 -04:00
parent 308a7f296f
commit 9adf5659bc

View File

@@ -41,6 +41,22 @@ def test_null_error_handling():
else:
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__":
test_error_formatting()
test_null_error_handling()
test_1364_schema_mismatch()