58 lines
2.7 KiB
Text
58 lines
2.7 KiB
Text
def fail [msg: string] {
|
|
error make {msg: $msg}
|
|
}
|
|
|
|
def assert-eq [actual expected msg: string] {
|
|
if $actual != $expected {
|
|
fail $"($msg): expected ($expected | to nuon), got ($actual | to nuon)"
|
|
}
|
|
}
|
|
|
|
def values [items] {
|
|
$items | default [] | get value
|
|
}
|
|
|
|
let completer = $env.config.completions.external.completer
|
|
|
|
def _assert_elevation_wrappers_accept_command_tails [p: path] {
|
|
sudo nix-env --set -p /nix/var/nix/profiles/system $p
|
|
doas nix-env --set -p /nix/var/nix/profiles/system $p
|
|
}
|
|
|
|
'[{"value":"--static","description":"from static cache"}]' | save --force $env.INSHELLAH_STATIC_FILE
|
|
let static_result = do $completer [demo ""]
|
|
assert-eq ($static_result | get 0.value) "--static" "static completion pass-through"
|
|
|
|
"{" | save --force $env.INSHELLAH_STATIC_FILE
|
|
let bad_static_result = do $completer [demo ""]
|
|
assert-eq $bad_static_result null "bad static JSON falls back cleanly"
|
|
"" | save --force $env.INSHELLAH_STATIC_FILE
|
|
|
|
assert-eq (do $completer [nix]) null "nix completion ignores too-short spans"
|
|
let nix_commands = do $completer [nix ""]
|
|
assert-eq ($nix_commands | get 0.value) "build" "nix command completion uses NIX_GET_COMPLETIONS"
|
|
let nix_pkg = do $completer [nix "flake#pkg"]
|
|
assert-eq ($nix_pkg | get 0.description) "raw package description" "nix descriptions are raw strings"
|
|
|
|
let systemctl_empty = do $completer [systemctl daemon-reload ""]
|
|
assert-eq $systemctl_empty null "systemctl does not offer units for non-unit verbs"
|
|
let systemctl_units = do $completer [systemctl status ""]
|
|
assert-eq ($systemctl_units | get 0.value) "demo.service" "systemctl offers units for unit verbs"
|
|
|
|
let kubectl_pods = do $completer [kubectl get pods -n prod ""]
|
|
assert-eq ($kubectl_pods | get 0.value) "pod-a" "kubectl resource names complete"
|
|
assert-eq (open $env.KUBECTL_ARGS_FILE | str contains "-n prod") true "kubectl preserves namespace flags"
|
|
let kubectl_rollout = do $completer [kubectl rollout status deployment ""]
|
|
assert-eq ($kubectl_rollout | get 0.description) "deployment" "kubectl rollout uses resource kind, not action"
|
|
|
|
let cargo_packages = do $completer [cargo test -p ""]
|
|
assert-eq (values $cargo_packages) [app-lib helper-lib] "cargo -p completes packages"
|
|
let cargo_bins = do $completer [cargo run --bin ""]
|
|
assert-eq (values $cargo_bins) [app-cli] "cargo --bin completes only bin targets"
|
|
|
|
let git_push = do $completer [git push ""]
|
|
assert-eq (values $git_push) [origin upstream] "git push first argument completes remotes"
|
|
let git_worktree_add = do $completer [git worktree add ""]
|
|
assert-eq $git_worktree_add null "git worktree add first argument falls back to files"
|
|
let git_worktree_remove = do $completer [git worktree remove ""]
|
|
assert-eq ($git_worktree_remove | get 0.value) "/repo/linked" "git worktree remove completes existing worktrees"
|