GRM-16: test: add molecule lifecycle scenarios, integration tests, and docs
- Add multi-instance molecule scenario verifying isolated data/config dirs - Add lifecycle molecule scenario testing stop/disable/enable/start sequence - Update default and binary verify playbooks for template unit assertions - Add integration tests for full CLI lifecycle and multi-instance support - Add pytest integration marker and --no-cov Makefile target - Update README with lifecycle commands, multi-instance examples, and architecture - Update Makefile with start/stop/enable/disable/status/remove targets - Update .env.example with GRM_LANG documentation
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
"""Integration tests for Gitea Runner lifecycle commands."""
|
||||
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
from click.testing import CliRunner
|
||||
|
||||
from gitea_runner_manager.cli import cli
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
class TestLifecycleCLI:
|
||||
"""Test the full lifecycle CLI commands end-to-end."""
|
||||
|
||||
@patch("gitea_runner_manager.cli.RunnerManager")
|
||||
def test_install_start_status_stop_disable_remove(self, mock_manager_class: MagicMock) -> None:
|
||||
"""Exercise the full lifecycle via CLI."""
|
||||
mock_manager = MagicMock()
|
||||
mock_manager_class.return_value = mock_manager
|
||||
|
||||
env = {"GITEA_URL": "https://git.example.com", "GITEA_REGISTRATION_TOKEN": "tok"}
|
||||
runner = CliRunner(env=env)
|
||||
|
||||
# Install
|
||||
result = runner.invoke(cli, ["install", "host1", "--user", "ubuntu", "--name", "r1"])
|
||||
assert result.exit_code == 0
|
||||
mock_manager.install.assert_called_once()
|
||||
|
||||
# Start
|
||||
result = runner.invoke(cli, ["start", "host1", "--user", "ubuntu", "--name", "r1"])
|
||||
assert result.exit_code == 0
|
||||
mock_manager.start.assert_called_once_with(
|
||||
host="host1", user="ubuntu", name="r1", mode="docker", ask_become_pass=False
|
||||
)
|
||||
|
||||
# Status
|
||||
result = runner.invoke(cli, ["status", "host1", "--user", "ubuntu", "--name", "r1"])
|
||||
assert result.exit_code == 0
|
||||
mock_manager.status.assert_called_once_with(
|
||||
host="host1", user="ubuntu", name="r1", mode="docker", ask_become_pass=False
|
||||
)
|
||||
|
||||
# Stop
|
||||
result = runner.invoke(cli, ["stop", "host1", "--user", "ubuntu", "--name", "r1"])
|
||||
assert result.exit_code == 0
|
||||
mock_manager.stop.assert_called_once_with(host="host1", user="ubuntu", name="r1", ask_become_pass=False)
|
||||
|
||||
# Disable
|
||||
result = runner.invoke(cli, ["disable", "host1", "--user", "ubuntu", "--name", "r1", "--token", "tok"])
|
||||
assert result.exit_code == 0
|
||||
mock_manager.disable.assert_called_once_with(
|
||||
host="host1",
|
||||
user="ubuntu",
|
||||
name="r1",
|
||||
token="tok",
|
||||
gitea_url="https://git.example.com",
|
||||
mode="docker",
|
||||
ask_become_pass=False,
|
||||
)
|
||||
|
||||
# Remove
|
||||
result = runner.invoke(cli, ["remove", "host1", "--user", "ubuntu", "--name", "r1", "--token", "tok"])
|
||||
assert result.exit_code == 0
|
||||
mock_manager.remove.assert_called_once_with(
|
||||
host="host1",
|
||||
user="ubuntu",
|
||||
name="r1",
|
||||
token="tok",
|
||||
gitea_url="https://git.example.com",
|
||||
mode="docker",
|
||||
ask_become_pass=False,
|
||||
)
|
||||
Reference in New Issue
Block a user