example
This commit is contained in:
@@ -36,6 +36,43 @@ def test_complete_package_remove(monkeypatch):
|
||||
assert out == ["hello"]
|
||||
|
||||
|
||||
def test_list_manifest_packages_is_consistent_for_list_and_dict_forms(monkeypatch):
|
||||
manifests = [
|
||||
{
|
||||
"packages": [
|
||||
{"name": "neovim", "type": "binary"},
|
||||
{"name": "ripgrep", "type": "pkg"},
|
||||
{"name": "fzf", "type": "binary"},
|
||||
]
|
||||
},
|
||||
{
|
||||
"packages": {
|
||||
"neovim": {"type": "binary"},
|
||||
"ripgrep": {"type": "pkg"},
|
||||
"fzf": {"type": "binary"},
|
||||
}
|
||||
},
|
||||
]
|
||||
|
||||
monkeypatch.setattr(completion, "_safe_manifest", lambda: manifests.pop(0))
|
||||
|
||||
from_list = completion._list_manifest_packages()
|
||||
from_dict = completion._list_manifest_packages()
|
||||
|
||||
assert from_list == ["fzf", "neovim"]
|
||||
assert from_dict == ["fzf", "neovim"]
|
||||
|
||||
|
||||
def test_list_manifest_packages_uses_mapping_key_when_name_missing(monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
completion,
|
||||
"_safe_manifest",
|
||||
lambda: {"packages": {"bat": {"type": "binary"}, "git": {"type": "pkg"}}},
|
||||
)
|
||||
|
||||
assert completion._list_manifest_packages() == ["bat"]
|
||||
|
||||
|
||||
def test_complete_dotfiles_profile_value(monkeypatch):
|
||||
monkeypatch.setattr(completion, "_list_dotfiles_profiles", lambda: ["work", "personal"])
|
||||
out = completion.complete(["flow", "dotfiles", "link", "--profile", "w"], 5)
|
||||
@@ -47,6 +84,17 @@ def test_complete_dotfiles_repo_subcommands():
|
||||
assert out == ["pull", "push"]
|
||||
|
||||
|
||||
def test_complete_dotfiles_modules_subcommands():
|
||||
out = completion.complete(["flow", "dotfiles", "modules", "s"], 4)
|
||||
assert out == ["sync"]
|
||||
|
||||
|
||||
def test_complete_dotfiles_modules_profile_value(monkeypatch):
|
||||
monkeypatch.setattr(completion, "_list_dotfiles_profiles", lambda: ["work", "personal"])
|
||||
out = completion.complete(["flow", "dotfiles", "modules", "list", "--profile", "w"], 6)
|
||||
assert out == ["work"]
|
||||
|
||||
|
||||
def test_complete_enter_targets(monkeypatch):
|
||||
monkeypatch.setattr(completion, "_list_targets", lambda: ["personal@orb", "work@ec2"])
|
||||
out = completion.complete(["flow", "enter", "p"], 3)
|
||||
|
||||
Reference in New Issue
Block a user