Add lightweight unittest coverage for stability fixes
This commit is contained in:
21
tests/test_disk_report.py
Normal file
21
tests/test_disk_report.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import unittest
|
||||
import types
|
||||
import sys
|
||||
|
||||
# Avoid runtime import of real app/aiogram in services.runner.
|
||||
sys.modules.setdefault("app", types.SimpleNamespace(RESTIC_ENV={}))
|
||||
|
||||
from services.disk_report import _top_dirs_cmd
|
||||
|
||||
|
||||
class DiskReportTests(unittest.TestCase):
|
||||
def test_top_dirs_cmd_uses_exec_args_without_shell(self):
|
||||
cmd = _top_dirs_cmd("/tmp/path with spaces", 5)
|
||||
self.assertEqual(cmd[:4], ["du", "-x", "-h", "-d"])
|
||||
self.assertNotIn("bash", cmd)
|
||||
self.assertNotIn("-lc", cmd)
|
||||
self.assertEqual(cmd[-1], "/tmp/path with spaces")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user