update
This commit is contained in:
@@ -2,7 +2,12 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from flow.commands.bootstrap import _get_profiles, _plan_actions
|
||||
from flow.commands.bootstrap import (
|
||||
_get_profiles,
|
||||
_plan_actions,
|
||||
_resolve_package_manager,
|
||||
_resolve_package_name,
|
||||
)
|
||||
from flow.core.config import AppConfig, FlowContext
|
||||
from flow.core.console import ConsoleLogger
|
||||
from flow.core.platform import PlatformInfo
|
||||
@@ -60,6 +65,22 @@ def test_plan_packages(ctx):
|
||||
assert "install-binary" in types
|
||||
|
||||
|
||||
def test_plan_packages_uses_package_map(ctx):
|
||||
ctx.manifest["package-map"] = {
|
||||
"fd": {"apt": "fd-find"},
|
||||
}
|
||||
env_config = {
|
||||
"package-manager": "apt",
|
||||
"packages": {
|
||||
"standard": ["fd"],
|
||||
},
|
||||
}
|
||||
|
||||
actions = _plan_actions(ctx, "test", env_config, {})
|
||||
install = [a for a in actions if a.type == "install-packages"][0]
|
||||
assert install.data["packages"] == ["fd-find"]
|
||||
|
||||
|
||||
def test_plan_ssh_keygen(ctx):
|
||||
env_config = {
|
||||
"ssh_keygen": [
|
||||
@@ -127,3 +148,41 @@ def test_get_profiles_rejects_environments(ctx):
|
||||
ctx.manifest = {"environments": {"legacy": {"os": "linux"}}}
|
||||
with pytest.raises(RuntimeError, match="no longer supported"):
|
||||
_get_profiles(ctx)
|
||||
|
||||
|
||||
def test_resolve_package_manager_explicit_value(ctx):
|
||||
assert _resolve_package_manager(ctx, {"package-manager": "dnf"}) == "dnf"
|
||||
|
||||
|
||||
def test_resolve_package_manager_linux_ubuntu(ctx):
|
||||
os_release = "ID=ubuntu\nID_LIKE=debian"
|
||||
assert _resolve_package_manager(ctx, {}, os_release_text=os_release) == "apt"
|
||||
|
||||
|
||||
def test_resolve_package_manager_linux_fedora(ctx):
|
||||
os_release = "ID=fedora\nID_LIKE=rhel"
|
||||
assert _resolve_package_manager(ctx, {}, os_release_text=os_release) == "dnf"
|
||||
|
||||
|
||||
def test_resolve_package_name_with_package_map(ctx):
|
||||
ctx.manifest["package-map"] = {
|
||||
"fd": {
|
||||
"apt": "fd-find",
|
||||
"dnf": "fd-find",
|
||||
"brew": "fd",
|
||||
}
|
||||
}
|
||||
assert _resolve_package_name(ctx, "fd", "apt") == "fd-find"
|
||||
assert _resolve_package_name(ctx, "fd", "dnf") == "fd-find"
|
||||
assert _resolve_package_name(ctx, "fd", "brew") == "fd"
|
||||
|
||||
|
||||
def test_resolve_package_name_falls_back_with_warning(ctx):
|
||||
warnings = []
|
||||
ctx.console.warn = warnings.append
|
||||
ctx.manifest["package-map"] = {"python3-dev": {"apt": "python3-dev"}}
|
||||
|
||||
resolved = _resolve_package_name(ctx, "python3-dev", "dnf", warn_missing=True)
|
||||
|
||||
assert resolved == "python3-dev"
|
||||
assert warnings
|
||||
|
||||
Reference in New Issue
Block a user