|
| 1 | +import os |
| 2 | +import shutil |
1 | 3 | from pathlib import Path |
2 | 4 |
|
3 | 5 | import pytest |
@@ -104,6 +106,30 @@ def test_masters(self, testdata_config): |
104 | 106 | secondary_repo = testdata_config.repos["dependent-secondary"] |
105 | 107 | assert secondary_repo.masters == (primary_repo,) |
106 | 108 |
|
| 109 | + def test_pkg_metadata_regen(self, testdata_config, tmpdir): |
| 110 | + orig_repo = testdata_config.repos["metadata-gen"] |
| 111 | + # copy original repo to a temp dir |
| 112 | + repo_path = shutil.copytree(orig_repo.path, tmpdir.join("repo")) |
| 113 | + repo = EbuildRepo(repo_path) |
| 114 | + metadata_path = repo.path.joinpath("metadata/md5-cache") |
| 115 | + |
| 116 | + def metadata_content(): |
| 117 | + """Yield metadata file names and content.""" |
| 118 | + for root, _dirs, files in os.walk(metadata_path): |
| 119 | + for name in files: |
| 120 | + with open(os.path.join(root, name)) as f: |
| 121 | + yield (name, f.read()) |
| 122 | + |
| 123 | + # record expected metadata file content |
| 124 | + expected = sorted(metadata_content()) |
| 125 | + # wipe metadata |
| 126 | + shutil.rmtree(metadata_path) |
| 127 | + # regenerate metadata |
| 128 | + repo.pkg_metadata_regen() |
| 129 | + # verify new data matches original |
| 130 | + data = sorted(metadata_content()) |
| 131 | + assert data == expected |
| 132 | + |
107 | 133 |
|
108 | 134 | class TestEbuildRepoMetadata: |
109 | 135 | def test_arches(self, make_ebuild_repo): |
|
0 commit comments