feat: enhanced mute system to allow for tag-specific mute/unmuting

This commit is contained in:
Lewis Wynne 2026-04-02 16:34:53 +01:00
parent 9a39e22d52
commit f68a92323c
2 changed files with 148 additions and 20 deletions

View file

@ -2,19 +2,35 @@
load test_helper
@test "mute creates muted file" {
@test "mute with no args creates mute file with global entry" {
run_nag mute
[ "${status}" -eq 0 ]
[[ "${output}" =~ "muted" ]]
[ -f "${NAG_DIR}/muted" ]
[[ "${output}" =~ "Muted all." ]]
[ -f "${NAG_DIR}/mute" ]
grep -q "^\*$" "${NAG_DIR}/mute"
}
@test "unmute removes muted file" {
@test "mute tag adds tag to mute file" {
run_nag mute work
[ "${status}" -eq 0 ]
[[ "${output}" =~ "Muted [work]." ]]
grep -q "^work$" "${NAG_DIR}/mute"
}
@test "mute tag skips if global mute already set" {
run_nag mute
run_nag mute work
[ "${status}" -eq 0 ]
[[ "${output}" =~ "Muted [work]." ]]
[ "$(wc -l < "${NAG_DIR}/mute")" -eq 1 ]
}
@test "unmute with no args deletes mute file" {
run_nag mute
run_nag unmute
[ "${status}" -eq 0 ]
[[ "${output}" =~ "unmuted" ]]
[ ! -f "${NAG_DIR}/muted" ]
[[ "${output}" =~ "Unmuted all." ]]
[ ! -f "${NAG_DIR}/mute" ]
}
@test "unmute when not muted says so" {
@ -22,3 +38,19 @@ load test_helper
[ "${status}" -eq 0 ]
[[ "${output}" =~ "not muted" ]]
}
@test "unmute tag adds !tag when global mute is set" {
run_nag mute
run_nag unmute work
[ "${status}" -eq 0 ]
[[ "${output}" =~ "Unmuted [work]." ]]
grep -q "^!work$" "${NAG_DIR}/mute"
}
@test "unmute tag removes tag entry when individually muted" {
run_nag mute work
run_nag unmute work
[ "${status}" -eq 0 ]
[[ "${output}" =~ "Unmuted [work]." ]]
! grep -q "^work$" "${NAG_DIR}/mute"
}