From 4b66bcb2a721c0110e5be6f03d5bf5efb350b897 Mon Sep 17 00:00:00 2001 From: krishna sindhur Date: Thu, 29 May 2025 15:11:43 +0530 Subject: [PATCH] fix: stress test will ignore unique constraint violation --- stress/main.rs | 3 +++ testing/insert.test | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/stress/main.rs b/stress/main.rs index 743ff5722..8bd2c3837 100644 --- a/stress/main.rs +++ b/stress/main.rs @@ -438,6 +438,9 @@ async fn main() -> Result<(), Box> { limbo::Error::SqlExecutionFailure(e) => { if e.contains("Corrupt database") { panic!("Error executing query: {}", e); + } else if e.contains("UNIQUE constraint failed") { + println!("Skipping UNIQUE constraint violation: {}", e); + continue; } else { println!("Error executing query: {}", e); } diff --git a/testing/insert.test b/testing/insert.test index 29d18d651..ecc129631 100755 --- a/testing/insert.test +++ b/testing/insert.test @@ -130,12 +130,12 @@ do_execsql_test_in_memory_any_error strict-update-not-null-constraint { } # Uncomment following test case when unique constraint is added -#do_execsql_test_any_error strict-update-pk-constraint { -# CREATE TABLE test8(id INTEGER PRIMARY KEY, name TEXT) STRICT; -# INSERT INTO test8 VALUES(1, 'name1'); -# INSERT INTO test8 VALUES(2, 'name2'); -# UPDATE test8 SET id = 2 WHERE id = 1; -#} +do_execsql_test_any_error strict-update-pk-constraint { + CREATE TABLE test8(id INTEGER PRIMARY KEY, name TEXT) STRICT; + INSERT INTO test8 VALUES(1, 'name1'); + INSERT INTO test8 VALUES(2, 'name2'); + UPDATE test8 SET id = 2 WHERE id = 1; +} do_execsql_test_on_specific_db {:memory:} strict-update-multiple-columns { CREATE TABLE test9(id INTEGER, name TEXT, price REAL, quantity INT) STRICT;