mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-22 02:40:02 +00:00
test(stock): savepoint around expected duplicate Bin insert (Postgres)
The deliberate UniqueValidationError from the second Bin insert aborts the transaction on Postgres, so the following _create_bin() (which takes its own savepoint) failed with InFailedSqlTransaction. Wrap the expected-failure insert in a savepoint and roll back to it, mirroring _create_bin's 'preserve transaction in postgres' pattern. No-op on MariaDB.
This commit is contained in:
@@ -19,8 +19,10 @@ class TestBin(ERPNextTestSuite):
|
||||
bin1.insert()
|
||||
|
||||
bin2 = frappe.get_doc(doctype="Bin", item_code=item_code, warehouse=warehouse)
|
||||
frappe.db.savepoint("dup_bin")
|
||||
with self.assertRaises(frappe.UniqueValidationError):
|
||||
bin2.insert()
|
||||
frappe.db.rollback(save_point="dup_bin") # preserve transaction in postgres
|
||||
|
||||
# util method should handle it
|
||||
bin = _create_bin(item_code, warehouse)
|
||||
|
||||
Reference in New Issue
Block a user