Test that transaction rolls back when exception is raised.
(testrepo: Repository)
| 49 | |
| 50 | |
| 51 | def test_transaction_rollback_on_exception(testrepo: Repository) -> None: |
| 52 | """Test that transaction rolls back when exception is raised.""" |
| 53 | master_ref = testrepo.lookup_reference('refs/heads/master') |
| 54 | original_target = master_ref.target |
| 55 | |
| 56 | new_target = Oid(hex='5ebeeebb320790caf276b9fc8b24546d63316533') |
| 57 | |
| 58 | # Transaction should not commit if exception is raised |
| 59 | with pytest.raises(RuntimeError): |
| 60 | with testrepo.transaction() as txn: |
| 61 | txn.lock_ref('refs/heads/master') |
| 62 | txn.set_target('refs/heads/master', new_target, message='Test update') |
| 63 | raise RuntimeError('Abort transaction') |
| 64 | |
| 65 | # Verify the update was NOT applied |
| 66 | master_ref = testrepo.lookup_reference('refs/heads/master') |
| 67 | assert master_ref.target == original_target |
| 68 | |
| 69 | |
| 70 | def test_transaction_multiple_refs(testrepo: Repository) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…