feat: add all services (dotfiles, packages, bootstrap, remote, containers, projects)
- DotfilesService: package discovery, module sync, link/unlink/status - PackageService: install/remove/list with PM and binary support - BootstrapService: profile-based system setup orchestration - RemoteService: SSH target resolution and connection - ContainerService: docker container lifecycle management - ProjectService: git repo status checking 26 service tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
62
tests/test_service_remote.py
Normal file
62
tests/test_service_remote.py
Normal file
@@ -0,0 +1,62 @@
|
||||
"""Tests for RemoteService."""
|
||||
|
||||
import pytest
|
||||
|
||||
from flow.core.config import AppConfig, FlowContext, TargetConfig
|
||||
from flow.core.console import Console
|
||||
from flow.core.errors import FlowError
|
||||
from flow.core.platform import PlatformInfo
|
||||
from flow.core.runtime import SystemRuntime
|
||||
from flow.services.remote import RemoteService
|
||||
|
||||
|
||||
def _make_ctx(targets=None):
|
||||
return FlowContext(
|
||||
config=AppConfig(targets=targets or []),
|
||||
manifest={},
|
||||
platform=PlatformInfo(),
|
||||
console=Console(color=False),
|
||||
runtime=SystemRuntime(),
|
||||
)
|
||||
|
||||
|
||||
class TestRemoteService:
|
||||
def test_enter_dry_run(self, capsys):
|
||||
targets = [TargetConfig(namespace="personal", platform="orb", host="personal.orb")]
|
||||
ctx = _make_ctx(targets)
|
||||
svc = RemoteService(ctx)
|
||||
svc.enter("personal@orb", dry_run=True)
|
||||
output = capsys.readouterr().out
|
||||
assert "personal@orb" in output
|
||||
assert "ssh" in output
|
||||
|
||||
def test_enter_unknown_target(self):
|
||||
ctx = _make_ctx()
|
||||
svc = RemoteService(ctx)
|
||||
with pytest.raises(FlowError, match="Unknown target"):
|
||||
svc.enter("missing@host")
|
||||
|
||||
def test_list_targets(self, capsys):
|
||||
targets = [
|
||||
TargetConfig(namespace="personal", platform="orb", host="personal.orb"),
|
||||
TargetConfig(namespace="work", platform="ec2", host="work.ec2"),
|
||||
]
|
||||
ctx = _make_ctx(targets)
|
||||
svc = RemoteService(ctx)
|
||||
svc.list()
|
||||
output = capsys.readouterr().out
|
||||
assert "personal@orb" in output
|
||||
assert "work@ec2" in output
|
||||
|
||||
def test_list_empty(self, capsys):
|
||||
ctx = _make_ctx()
|
||||
svc = RemoteService(ctx)
|
||||
svc.list()
|
||||
assert "No targets" in capsys.readouterr().out
|
||||
|
||||
def test_fix_terminfo(self, capsys):
|
||||
ctx = _make_ctx()
|
||||
svc = RemoteService(ctx)
|
||||
svc.fix_terminfo("personal@orb")
|
||||
output = capsys.readouterr().out
|
||||
assert "infocmp" in output
|
||||
Reference in New Issue
Block a user