|
| 1 | +import os |
| 2 | +import tomllib |
| 3 | +import pytest |
| 4 | + |
| 5 | +def get_commands(): |
| 6 | + path = ".gemini/commands/" |
| 7 | + return [os.path.join(path, f) for f in os.listdir(path) if f.endswith(".toml")] |
| 8 | + |
| 9 | +def get_agents(): |
| 10 | + path = ".gemini/agents/" |
| 11 | + return [os.path.join(path, f) for f in os.listdir(path) if f.endswith(".md")] |
| 12 | + |
| 13 | +@pytest.mark.parametrize("cmd_path", get_commands()) |
| 14 | +def test_command_structure(cmd_path): |
| 15 | + with open(cmd_path, "rb") as f: |
| 16 | + config = tomllib.load(f) |
| 17 | + |
| 18 | + assert "description" in config |
| 19 | + assert isinstance(config["description"], str) |
| 20 | + assert len(config["description"].strip()) > 0 |
| 21 | + |
| 22 | + assert "prompt" in config |
| 23 | + assert isinstance(config["prompt"], str) |
| 24 | + assert len(config["prompt"].strip()) > 0 |
| 25 | + |
| 26 | +@pytest.mark.parametrize("agent_path", get_agents()) |
| 27 | +def test_agent_structure(agent_path): |
| 28 | + agent_name = os.path.basename(agent_path).replace(".md", "") |
| 29 | + with open(agent_path, "r") as f: |
| 30 | + content = f.read() |
| 31 | + |
| 32 | + # Check for name in content (case-insensitive) |
| 33 | + assert agent_name.lower() in content.lower() |
| 34 | + |
| 35 | + # Check for some basic structure (e.g. name: or # Title) |
| 36 | + assert f"name: {agent_name}" in content.lower() or f"# {agent_name}" in content.lower() |
0 commit comments