Test that committing a transaction from wrong thread raises error.
(testrepo: Repository)
| 253 | |
| 254 | |
| 255 | def test_transaction_commit_from_wrong_thread(testrepo: Repository) -> None: |
| 256 | """Test that committing a transaction from wrong thread raises error.""" |
| 257 | txn: ReferenceTransaction | None = None |
| 258 | |
| 259 | def create_transaction() -> None: |
| 260 | nonlocal txn |
| 261 | txn = testrepo.transaction().__enter__() |
| 262 | ref_name = 'refs/heads/wrong-thread-test' |
| 263 | target = Oid(hex='5ebeeebb320790caf276b9fc8b24546d63316533') |
| 264 | testrepo.create_reference(ref_name, target) |
| 265 | txn.lock_ref(ref_name) |
| 266 | |
| 267 | # Create transaction in thread 1 |
| 268 | thread = threading.Thread(target=create_transaction) |
| 269 | thread.start() |
| 270 | thread.join() |
| 271 | |
| 272 | assert txn is not None |
| 273 | with pytest.raises(RuntimeError): |
| 274 | # Try to commit from main thread (different from creator) doesn't cause libgit2 to crash, |
| 275 | # it raises an exception instead |
| 276 | txn.commit() |
| 277 | |
| 278 | |
| 279 | def test_transaction_nested_same_thread(testrepo: Repository) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…