Developer tools dump stack traces, exit codes, and jargon. Figuring out *what to do next* often means searching the same Stack Overflow answers again.
| 1 | """Redis rule tests.""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | import pytest |
| 6 | |
| 7 | from why_failed.matcher import analyze |
| 8 | |
| 9 | CASES = [ |
| 10 | ("Error: connect ECONNREFUSED 127.0.0.1:6379", "redis.connection_refused"), |
| 11 | ("ReplyError: NOAUTH Authentication required.", "redis.noauth"), |
| 12 | ("ReplyError: WRONGPASS invalid username-password pair", "redis.wrongpass"), |
| 13 | ("ReplyError: READONLY You can't write against a read only replica.", "redis.readonly"), |
| 14 | ("ReplyError: MISCONF Redis is configured to save RDB snapshots", "redis.misconf"), |
| 15 | ("ReplyError: LOADING Redis is loading the dataset in memory", "redis.loading"), |
| 16 | ] |
| 17 | |
| 18 | |
| 19 | @pytest.mark.parametrize("text,rule_id", CASES) |
| 20 | def test_redis_rules(text: str, rule_id: str) -> None: |
| 21 | result = analyze(text) |
| 22 | assert result.match is not None |
| 23 | assert result.match.rule_id == rule_id |