mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-19 01:24:20 +01:00
antithesis-tests: Don't fail tests on unique constraint violation
Unique constraint violation is not an error.
This commit is contained in:
@@ -24,8 +24,16 @@ print(f'Inserting {insertions} rows...')
|
|||||||
|
|
||||||
for i in range(insertions):
|
for i in range(insertions):
|
||||||
values = [generate_random_value(tbl_schema[f'col_{col}']['data_type']) for col in range(tbl_schema['colCount'])]
|
values = [generate_random_value(tbl_schema[f'col_{col}']['data_type']) for col in range(tbl_schema['colCount'])]
|
||||||
cur.execute(f'''
|
try:
|
||||||
INSERT INTO tbl_{selected_tbl} ({cols})
|
cur.execute(f'''
|
||||||
VALUES ({', '.join(values)})
|
INSERT INTO tbl_{selected_tbl} ({cols})
|
||||||
''')
|
VALUES ({', '.join(values)})
|
||||||
|
''')
|
||||||
|
except limbo.OperationalError as e:
|
||||||
|
if "UNIQUE constraint failed" in str(e):
|
||||||
|
# Ignore UNIQUE constraint violations
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
# Re-raise other operational errors
|
||||||
|
raise
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,15 @@ for i in range(updates):
|
|||||||
where_clause = f"col_{pk} = {generate_random_value(tbl_schema[f'col_{pk}']['data_type'])}"
|
where_clause = f"col_{pk} = {generate_random_value(tbl_schema[f'col_{pk}']['data_type'])}"
|
||||||
# print(where_clause)
|
# print(where_clause)
|
||||||
|
|
||||||
cur.execute(f'''
|
try:
|
||||||
UPDATE tbl_{selected_tbl} SET {set_clause} WHERE {where_clause}
|
cur.execute(f'''
|
||||||
''')
|
UPDATE tbl_{selected_tbl} SET {set_clause} WHERE {where_clause}
|
||||||
|
''')
|
||||||
|
except limbo.OperationalError as e:
|
||||||
|
if "UNIQUE constraint failed" in str(e):
|
||||||
|
# Ignore UNIQUE constraint violations
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
# Re-raise other operational errors
|
||||||
|
raise
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user