Test that nested transactions fail when trying to lock the same ref.
(testrepo: Repository)
| 305 | |
| 306 | |
| 307 | def test_transaction_nested_same_ref_conflict(testrepo: Repository) -> None: |
| 308 | """Test that nested transactions fail when trying to lock the same ref.""" |
| 309 | ref_name = 'refs/heads/nested-conflict-test' |
| 310 | target = Oid(hex='5ebeeebb320790caf276b9fc8b24546d63316533') |
| 311 | new_target = Oid(hex='2be5719152d4f82c7302b1c0932d8e5f0a4a0e98') |
| 312 | testrepo.create_reference(ref_name, target) |
| 313 | |
| 314 | with testrepo.transaction() as txn1: |
| 315 | txn1.lock_ref(ref_name) |
| 316 | |
| 317 | # Inner transaction should fail to lock the same ref |
| 318 | with pytest.raises(GitError): |
| 319 | with testrepo.transaction() as txn2: |
| 320 | txn2.lock_ref(ref_name) |
| 321 | |
| 322 | # Outer transaction should still be able to complete |
| 323 | txn1.set_target(ref_name, new_target, message='Outer transaction') |
| 324 | |
| 325 | # Outer transaction's update should have been applied |
| 326 | ref = testrepo.lookup_reference(ref_name) |
| 327 | assert ref.target == new_target |
nothing calls this directly
no test coverage detected
searching dependent graphs…