Skip to content

Commit

Permalink
Add tests for the cli module.
Browse files Browse the repository at this point in the history
  • Loading branch information
eli64s committed Dec 4, 2023
1 parent 30f140f commit 908fd68
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tests/test_cli/test_commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""Unit tests for the CLI commands module."""

from click.testing import CliRunner
from readmeai.cli.commands import commands


def test_commands():
"""Test that the CLI command runs."""
runner = CliRunner()
result = runner.invoke(
commands, ["--repository", "https://github.com/example/repo"]
)
assert result.exit_code == 0


def test_commands_with_options():
"""Test that the CLI command runs with options."""
runner = CliRunner()
result = runner.invoke(
commands,
[
"--repository",
"https://github.com/example/repo",
"--api-key",
"your-api-key",
"--model",
"gpt-4",
"--temperature",
"0.8",
],
)
assert result.exit_code == 0


def test_commands_missing_repository():
"""Test that the CLI command fails when repository option is missing."""
runner = CliRunner()
result = runner.invoke(commands, ["--badges", "flat"])
assert result.exit_code != 0
assert "Usage: commands" in result.output


if __name__ == "__main__":
test_commands()
test_commands_with_options()
test_commands_missing_repository()
1 change: 1 addition & 0 deletions tests/test_cli/test_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Unit tests for the CLI options module."""

0 comments on commit 908fd68

Please sign in to comment.