giteabot backport / giteabot (push) Canceled after 0s
giteabot / giteabot (push) Canceled after 0s
release-nightly / nightly-binary (push) Canceled after 0s
release-nightly / nightly-container (push) Canceled after 0s
release-nightly-snapcraft / build-and-publish (push) Canceled after 0s
Assisted-by: Codex:GPT-5
28 lines
875 B
Python
28 lines
875 B
Python
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
from gita_deepwiki.artifacts import ArtifactCleaner
|
|
|
|
|
|
class ArtifactCleanerTest(unittest.TestCase):
|
|
def test_removes_only_commit_index(self):
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
root = Path(directory)
|
|
databases = root / "databases"
|
|
databases.mkdir()
|
|
sha = "a" * 40
|
|
index = databases / f"{sha}.pkl"
|
|
index.write_bytes(b"index")
|
|
ArtifactCleaner(root).remove_index(sha)
|
|
self.assertFalse(index.exists())
|
|
|
|
def test_rejects_unsafe_name(self):
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
with self.assertRaisesRegex(ValueError, "invalid commit SHA"):
|
|
ArtifactCleaner(Path(directory)).remove_index("../escape")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|