mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-30 07:08:24 +00:00
test(stock): savepoint around expected duplicate barcode save (Postgres)
The deliberate UniqueValidationError when re-adding a barcode aborts the transaction on Postgres, so the next frappe.get_doc() failed with InFailedSqlTransaction. Wrap the expected-failure save in a savepoint and roll back to it. No-op on MariaDB.
This commit is contained in:
@@ -751,7 +751,9 @@ class TestItem(ERPNextTestSuite):
|
||||
item_doc = frappe.get_doc("Item", item_code)
|
||||
new_barcode = item_doc.append("barcodes")
|
||||
new_barcode.update(barcode_properties_list[0])
|
||||
frappe.db.savepoint("dup_barcode")
|
||||
self.assertRaises(frappe.UniqueValidationError, item_doc.save)
|
||||
frappe.db.rollback(save_point="dup_barcode") # preserve transaction in postgres
|
||||
|
||||
# Add invalid barcode - should cause InvalidBarcode
|
||||
item_doc = frappe.get_doc("Item", item_code)
|
||||
|
||||
Reference in New Issue
Block a user