|
21 | 21 | from persistent.list import PersistentList |
22 | 22 | from persistent.mapping import PersistentMapping |
23 | 23 |
|
| 24 | +from renku.core import errors |
24 | 25 | from renku.domain_model.entity import Entity |
25 | 26 | from renku.domain_model.provenance.activity import Activity, Usage |
26 | 27 | from renku.domain_model.workflow.plan import Plan |
@@ -414,3 +415,27 @@ def test_database_immutable_object(database): |
414 | 415 |
|
415 | 416 | assert isinstance(usage_1, Usage) |
416 | 417 | assert usage_1 is usage_2 |
| 418 | + |
| 419 | + |
| 420 | +@pytest.mark.parametrize( |
| 421 | + "content,error_message", |
| 422 | + [ |
| 423 | + ("{'a':<' ' b}", ".*file' couldn't be loaded because it is corrupted.$"), |
| 424 | + ( |
| 425 | + "{'name': \n<<<<<<< HEAD:file\n'a'\n=======\n'b'\n>>>>>>> abcdefg:file\n}", |
| 426 | + ".*file' couldn't be loaded because it is corrupted.\n" |
| 427 | + "This is likely due to an unresolved git merge conflict in the file.$", |
| 428 | + ), |
| 429 | + ], |
| 430 | +) |
| 431 | +def test_database_corrupt_metadata(tmpdir, content, error_message): |
| 432 | + """Test raising correct error for corrupt metadata.""" |
| 433 | + from renku.infrastructure.database import Storage |
| 434 | + |
| 435 | + storage = Storage(tmpdir) |
| 436 | + |
| 437 | + with open(storage.path / "file", "w") as f: |
| 438 | + f.write(content) |
| 439 | + |
| 440 | + with pytest.raises(expected_exception=errors.MetadataCorruptError, match=error_message): |
| 441 | + storage.load("file") |
0 commit comments