chore: initial scaffolding of nag based on bash-boilerplate

This commit is contained in:
Lewis Wynne 2026-04-01 19:45:20 +01:00
commit d4319e1ef6
4 changed files with 507 additions and 0 deletions

27
test/nag.bats Normal file
View file

@ -0,0 +1,27 @@
#!/usr/bin/env bats
load test_helper
@test "list with no alarms prints nothing-to-nag message" {
run_nag
[ "${status}" -eq 0 ]
[ "${output}" = "Nothing to nag about." ]
}
@test "help shows usage" {
run_nag help
[ "${status}" -eq 0 ]
[[ "${output}" =~ "<time> <message...>" ]]
[[ "${output}" =~ "every <rules> <time> <message...>" ]]
[[ "${output}" =~ "stop <id>" ]]
[[ "${output}" =~ "skip <id>" ]]
[[ "${output}" =~ "check" ]]
[[ "${output}" =~ "help [<subcommand>]" ]]
[[ "${output}" =~ "Options:" ]]
}
@test "version shows version" {
run_nag version
[ "${status}" -eq 0 ]
[[ "${output}" =~ ^[0-9]+\.[0-9]+(_[a-zA-Z0-9]+)*$ ]]
}

19
test/test_helper.bash Normal file
View file

@ -0,0 +1,19 @@
# test/test_helper.bash
# Shared setup/teardown for nag tests.
_NAG="$(cd "$(dirname "${BATS_TEST_FILENAME}")/.." && pwd)/nag"
setup() {
export NAG_PATH
NAG_PATH="$(mktemp)"
rm -f "${NAG_PATH}"
export NAG_CMD="true"
}
teardown() {
rm -f "${NAG_PATH}" "${NAG_PATH}.lock"
}
run_nag() {
run "${_NAG}" --yes "$@"
}