tmux-party/tests/10-skeleton.bats
veg 698fff91ee fix: consistent usage errors for list, leave, status, who, log
list ignored --help and listed parties; leave and status ignored stray
arguments; who silently kept the last of several positionals; log took
a positional name that neither its usage nor the man page documents.
All now follow the parser convention of the other subcommands: help on
-h, exit 2 on an unknown flag or unexpected argument.
2026-09-21 09:33:36 +00:00

55 lines
1.4 KiB
Bash

#!/usr/bin/env bats
load 'helpers'
setup() { setup_party_sandbox; }
teardown() { teardown_party_sandbox; }
@test "party with no args prints usage and exits non-zero" {
run "$PARTY_BIN"
[ "$status" -ne 0 ]
[[ "$output" == *"Usage:"* ]]
[[ "$output" == *"host"* ]]
[[ "$output" == *"join"* ]]
}
@test "party --help prints usage and exits zero" {
run "$PARTY_BIN" --help
[ "$status" -eq 0 ]
[[ "$output" == *"Usage:"* ]]
}
@test "party rejects unknown subcommands" {
run "$PARTY_BIN" rumpelstiltskin
[ "$status" -ne 0 ]
[[ "$output" == *"unknown subcommand"* ]]
}
@test "library mode: source returns without dispatching" {
load_party_lib
# If the script ran dispatch, we'd never get here. Reaching this
# assertion is the test.
[ -n "${PARTY_VERSION:-}" ]
}
@test "no-argument subcommands print help and reject stray args" {
for sub in list leave status; do
run "$PARTY_BIN" "$sub" --help
[ "$status" -eq 0 ]
[[ "$output" == "Usage: party $sub" ]]
run "$PARTY_BIN" "$sub" stray
[ "$status" -eq 2 ]
[[ "$output" == *"unexpected arg 'stray'"* ]]
run "$PARTY_BIN" "$sub" --bogus
[ "$status" -eq 2 ]
done
}
@test "who rejects a second positional, log rejects any" {
run "$PARTY_BIN" who one two
[ "$status" -eq 2 ]
[[ "$output" == *"unexpected arg 'two'"* ]]
run "$PARTY_BIN" log one
[ "$status" -eq 2 ]
[[ "$output" == *"unexpected arg 'one'"* ]]
}