add tests

This commit is contained in:
Nathaniel Landau
2021-09-09 08:53:05 -04:00
parent 0caf491112
commit b5d12b8239
2 changed files with 31 additions and 0 deletions

View File

@@ -202,6 +202,24 @@ teardown() {
assert_line --index 5 ""
}
@test "_alert_: logging NOTICE" {
LOGLEVEL=NOTICE
run error "testing error"
run error "testing error 2"
run warning "testing warning"
run notice "testing notice"
run info "testing info"
run debug "testing debug"
set +o nounset
assert_file_exist "${LOGFILE}"
run cat "${LOGFILE}"
assert_line --index 0 --regexp "[0-9]+:[0-9]+:[0-9]+ \[ error\] \[.*\] testing error"
assert_line --index 1 --regexp "[0-9]+:[0-9]+:[0-9]+ \[ error\] \[.*\] testing error 2"
assert_line --index 2 --regexp "[0-9]+:[0-9]+:[0-9]+ \[warning\] \[.*\] testing warning"
assert_line --index 3 --regexp "[0-9]+:[0-9]+:[0-9]+ \[ notice\] \[.*\] testing notice"
assert_line --index 4 ""
}
@test "_alert_: logging DEBUG" {
LOGLEVEL=DEBUG
run error "testing error"

View File

@@ -85,6 +85,19 @@ teardown() {
assert_line --index 5 ""
}
@test "success and NOTICE level log" {
run $s --loglevel=NOTICE
assert_success
assert_output --partial "[ info] This is info text"
run cat "${TESTDIR}/logs/log.txt"
assert_line --index 0 --regexp "\[ notice\].*This is notice text"
assert_line --index 1 --regexp "\[warning\].*This is warning text"
assert_line --index 2 --regexp "\[ error\].*This is error text"
assert_line --index 3 --regexp "\[success\].*This is success text"
assert_line --index 4 ""
}
@test "Usage (-h)" {
run $s -h