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 | """Docker rule tests.""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | import pytest |
| 6 | |
| 7 | from why_failed.matcher import analyze |
| 8 | |
| 9 | CASES = [ |
| 10 | ("Bind for 0.0.0.0:8080 failed: port is already allocated", "docker.port_allocated"), |
| 11 | ("Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?", "docker.daemon_not_running"), |
| 12 | ("Conflict. The container name \"/web\" is already in use by container", "docker.name_in_use"), |
| 13 | ("Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock", "docker.permission_denied"), |
| 14 | ("no such service: redisx", "docker.no_such_service"), |
| 15 | ("ERROR [builder 3/5] RUN npm install\nfailed to solve: process returned non-zero", "docker.build_failed"), |
| 16 | ("network myapp_default not found", "docker.network_not_found"), |
| 17 | ] |
| 18 | |
| 19 | |
| 20 | @pytest.mark.parametrize("text,rule_id", CASES) |
| 21 | def test_docker_rules(text: str, rule_id: str) -> None: |
| 22 | result = analyze(text) |
| 23 | assert result.match is not None |
| 24 | assert result.match.rule_id == rule_id |