| ... | ... | @@ -106,6 +106,21 @@ class MirrorTests(unittest.TestCase): |
| 106 | 106 | with self.assertRaises(mirror.Unavailable): |
| 107 | 107 | self.cache.verify() |
| 108 | 108 | |
| 109 | def test_verify_ignores_download_locks_and_pending_archives(self): |
| 110 | name = 'zig-0.5.0.tar.xz' |
| 111 | body = b'verified historical archive' |
| 112 | checksum = mirror.hashlib.sha256(body).hexdigest() |
| 113 | with patch.object(mirror, 'fetch', side_effect=lambda url, target, limit: target.write_bytes(body)): |
| 114 | artifact = self.cache.ensure(name, checksum=checksum) |
| 115 | self.assertEqual((self.cache.root / '.mirror-locks' / name).stat().st_size, 0) |
| 116 | pending = artifact.parent / '.download-pending' / name |
| 117 | pending.parent.mkdir() |
| 118 | pending.write_bytes(b'incomplete corrupt bytes') |
| 119 | entries = {'0.5.0': {'src': {'tarball': mirror.upstream(name), 'shasum': checksum}}} |
| 120 | with patch.object(mirror, 'index', return_value=entries), contextlib.redirect_stdout(io.StringIO()) as output: |
| 121 | self.cache.verify() |
| 122 | self.assertEqual(json.loads(output.getvalue()), {'verifiedArtifacts': 1}) |
| 123 | |
| 109 | 124 | def test_http_query_range_head_denials_and_timeout(self): |
| 110 | 125 | target = self.cache.path('zig-0.17.0.tar.xz') |
| 111 | 126 | target.parent.mkdir() |