From 9adf5659bcca581732ac76ade401c65640f314f5 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Tue, 17 Mar 2026 19:08:48 -0400 Subject: [PATCH] test(errors): add unit test for 1364 schema mismatch error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- tests/unit/test_unit_errors.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/unit/test_unit_errors.py b/tests/unit/test_unit_errors.py index c009757..177a82b 100644 --- a/tests/unit/test_unit_errors.py +++ b/tests/unit/test_unit_errors.py @@ -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()