(
testrepo: Repository,
tmp_path: Path,
pack_delegate: Callable[[PackBuilder], None] | None,
)
| 90 | |
| 91 | |
| 92 | def confirm_same_repo_after_packing( |
| 93 | testrepo: Repository, |
| 94 | tmp_path: Path, |
| 95 | pack_delegate: Callable[[PackBuilder], None] | None, |
| 96 | ) -> None: |
| 97 | # Helper method to confirm the contents of two repos before and after packing |
| 98 | pack_repo = setup_second_repo(tmp_path) |
| 99 | pack_repo_path = Path(pack_repo.path) |
| 100 | |
| 101 | objects_dir = pack_repo_path / 'objects' |
| 102 | utils.rmtree(objects_dir) |
| 103 | pack_path = objects_dir / 'pack' |
| 104 | pack_path.mkdir(parents=True) |
| 105 | |
| 106 | # assert that the number of written objects is the same as the number of objects in the repo |
| 107 | written_objects = testrepo.pack(pack_path, pack_delegate=pack_delegate) |
| 108 | assert written_objects == len([obj for obj in testrepo]) |
| 109 | |
| 110 | # assert that the number of objects in the pack repo is the same as the original repo |
| 111 | orig_objects = [obj for obj in testrepo.odb] |
| 112 | packed_objects = [obj for obj in pack_repo.odb] |
| 113 | assert len(packed_objects) == len(orig_objects) |
| 114 | |
| 115 | # assert that the objects in the packed repo are the same objects as the original repo |
| 116 | for i, obj in enumerate(orig_objects): |
| 117 | assert pack_repo[obj].type == testrepo[obj].type |
| 118 | assert pack_repo[obj].read_raw() == testrepo[obj].read_raw() |
no test coverage detected
searching dependent graphs…