mirror of
https://github.com/natelandau/shell-scripting-templates.git
synced 2025-11-08 13:13:47 -05:00
add tests
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user