- Profile, BootstrapAction, BootstrapPlan models - Setup modules: hostname, locale, shell, ssh-keygen, runcmd - Bootstrap planning with ordered phases and env validation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
74 lines
1.9 KiB
Python
74 lines
1.9 KiB
Python
"""Tests for bootstrap setup modules."""
|
|
|
|
from flow.domain.bootstrap.modules import (
|
|
HostnameModule,
|
|
LocaleModule,
|
|
RuncmdModule,
|
|
ShellModule,
|
|
SSHKeygenModule,
|
|
)
|
|
|
|
|
|
class TestHostnameModule:
|
|
def test_describe(self):
|
|
m = HostnameModule(hostname="my-host")
|
|
assert isinstance(m.describe(), str)
|
|
assert "my-host" in m.describe()
|
|
|
|
def test_plan(self):
|
|
m = HostnameModule(hostname="my-host")
|
|
cmds = m.plan()
|
|
assert len(cmds) > 0
|
|
assert any("my-host" in c for c in cmds)
|
|
|
|
|
|
class TestLocaleModule:
|
|
def test_describe(self):
|
|
m = LocaleModule(locale="en_US.UTF-8")
|
|
assert isinstance(m.describe(), str)
|
|
assert "en_US.UTF-8" in m.describe()
|
|
|
|
def test_plan(self):
|
|
m = LocaleModule(locale="en_US.UTF-8")
|
|
cmds = m.plan()
|
|
assert len(cmds) > 0
|
|
|
|
|
|
class TestShellModule:
|
|
def test_describe(self):
|
|
m = ShellModule(shell="zsh")
|
|
assert isinstance(m.describe(), str)
|
|
assert "zsh" in m.describe()
|
|
|
|
def test_plan(self):
|
|
m = ShellModule(shell="zsh")
|
|
cmds = m.plan()
|
|
assert len(cmds) > 0
|
|
|
|
|
|
class TestSSHKeygenModule:
|
|
def test_describe(self):
|
|
m = SSHKeygenModule(keys=[{"path": "~/.ssh/id_ed25519"}])
|
|
assert isinstance(m.describe(), str)
|
|
assert "1" in m.describe()
|
|
|
|
def test_plan(self):
|
|
m = SSHKeygenModule(keys=[
|
|
{"path": "~/.ssh/id_ed25519", "type": "ed25519", "comment": "me@host"},
|
|
])
|
|
cmds = m.plan()
|
|
assert len(cmds) == 1
|
|
assert "ssh-keygen" in cmds[0]
|
|
|
|
|
|
class TestRuncmdModule:
|
|
def test_describe(self):
|
|
m = RuncmdModule(commands=["echo a", "echo b", "echo c"])
|
|
assert isinstance(m.describe(), str)
|
|
assert "3" in m.describe()
|
|
|
|
def test_plan(self):
|
|
m = RuncmdModule(commands=["echo hello"])
|
|
cmds = m.plan()
|
|
assert cmds == ["echo hello"]
|