58 lines
1.9 KiB
Nu
58 lines
1.9 KiB
Nu
use std/assert
|
|
use std/testing *
|
|
source _bundle.nu
|
|
|
|
# `source` is a parse-time keyword, so if any subcommand's argument/flag
|
|
# signature anywhere in the bundle were malformed, sourcing _bundle.nu
|
|
# above would already have failed before any test here could run. These
|
|
# tests additionally assert the full dispatch tree ends up registered
|
|
# under the names the real CLI is invoked with (`hermenix vm ssh` etc.
|
|
# dispatches to `main vm ssh`), without invoking any subcommand's body —
|
|
# same "parse only" check GUIDELINES.md recommends doing by hand.
|
|
|
|
def command-names [] {
|
|
scope commands | where name =~ '^main( |$)' | get name
|
|
}
|
|
|
|
@test
|
|
def "top-level subcommands are registered" [] {
|
|
let names = (command-names)
|
|
for n in [
|
|
"main" "main setup" "main migrate" "main migrate connections" "main remote"
|
|
"main vm" "main ctl" "main version"
|
|
] {
|
|
assert ($n in $names) $"missing top-level command: ($n)"
|
|
}
|
|
}
|
|
|
|
@test
|
|
def "vm subcommands are registered" [] {
|
|
let names = (command-names)
|
|
for n in [
|
|
"main vm ssh" "main vm console" "main vm start" "main vm stop"
|
|
"main vm restart" "main vm config" "main vm config-pull"
|
|
"main vm snapshot" "main vm snapshots" "main vm rollback"
|
|
"main vm backup" "main vm backups"
|
|
] {
|
|
assert ($n in $names) $"missing vm command: ($n)"
|
|
}
|
|
}
|
|
|
|
@test
|
|
def "ctl subcommands are registered" [] {
|
|
let names = (command-names)
|
|
for n in [
|
|
"main ctl" "main ctl soul" "main ctl memory" "main ctl conf"
|
|
"main ctl secrets" "main ctl status" "main ctl logs" "main ctl restart"
|
|
"main ctl units" "main ctl reseed" "main ctl pull"
|
|
] {
|
|
assert ($n in $names) $"missing ctl command: ($n)"
|
|
}
|
|
}
|
|
|
|
@test
|
|
def "vm rollback requires a snapshot argument" [] {
|
|
let sig = (scope commands | where name == "main vm rollback" | get 0.signatures)
|
|
assert (($sig | values | first | any {|p| $p.parameter_name == "snapshot"}))
|
|
}
|