test: add unit tests for core, parser and operations
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from sshctl.core.config import SshctlConfig, load_config
|
||||
|
||||
|
||||
def test_default_config() -> None:
|
||||
config = SshctlConfig()
|
||||
assert config.ssh_dir == Path("~/.ssh").expanduser()
|
||||
assert config.config_file == "config"
|
||||
assert config.verbose is False
|
||||
assert config.timeout == 10
|
||||
|
||||
|
||||
def test_config_env_prefix() -> None:
|
||||
assert SshctlConfig.model_config["env_prefix"] == "SSHCTL_"
|
||||
|
||||
|
||||
def test_ssh_config_path() -> None:
|
||||
config = SshctlConfig(ssh_dir=Path("/tmp/.ssh"))
|
||||
assert config.ssh_config_path() == Path("/tmp/.ssh/config")
|
||||
|
||||
|
||||
def test_conf_d_path() -> None:
|
||||
config = SshctlConfig(ssh_dir=Path("/tmp/.ssh"))
|
||||
assert config.conf_d_path() == Path("/tmp/.ssh/conf.d")
|
||||
|
||||
|
||||
def test_load_config_nonexistent() -> None:
|
||||
config = load_config(Path("/nonexistent/sshctl.yaml"))
|
||||
assert isinstance(config, SshctlConfig)
|
||||
Reference in New Issue
Block a user