diff --git a/test/alerts.bats b/test/alerts.bats index 887dbbd..68597a6 100755 --- a/test/alerts.bats +++ b/test/alerts.bats @@ -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" diff --git a/test/scriptTemplate.bats b/test/scriptTemplate.bats index 721fe0b..44e6521 100755 --- a/test/scriptTemplate.bats +++ b/test/scriptTemplate.bats @@ -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