Files
routeros-suricata-tzsp/tests/test_redis_service.py
T
2026-08-15 18:29:36 +02:00

23 lines
986 B
Python

import tempfile
from unittest.mock import patch
from app.redis_service import RedisSupervisor
def test_redis_uses_aof_everysec_and_rdb_snapshot():
with tempfile.TemporaryDirectory() as td:
supervisor = RedisSupervisor(True, td, port=6380, snapshot_seconds=900, aof=True)
supervisor.executable = "/usr/bin/redis-server"
with patch("app.redis_service.subprocess.Popen") as popen:
process = popen.return_value
process.poll.return_value = None
process.pid = 123
supervisor._spawn()
cmd = popen.call_args.args[0]
assert cmd[cmd.index("--appendonly") + 1] == "yes"
assert cmd[cmd.index("--appendfsync") + 1] == "everysec"
assert cmd[cmd.index("--save") + 1:cmd.index("--save") + 3] == ["900", "100"]
assert cmd[cmd.index("--dir") + 1] == td
assert cmd[cmd.index("--maxmemory") + 1] == "0"
assert cmd[cmd.index("--maxmemory-policy") + 1] == "noeviction"