test: Add lib log basic testing

pull/1623/head
Noah Gorny 2020-06-23 15:59:14 +03:00
parent 3e7a95660f
commit 5263f5ac59
1 changed files with 79 additions and 0 deletions

79
test/lib/log.bats 100644
View File

@ -0,0 +1,79 @@
#!/usr/bin/env bats
load ../test_helper
load ../../lib/composure
load ../../lib/appearance
load ../../plugins/available/base.plugin
cite _about _param _example _group _author _version
load ../../lib/log
@test "lib log: basic debug logging with BASH_IT_LOG_LEVEL_ALL" {
BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_ALL
run _log_debug "test test test"
assert_output "DEBUG: test test test"
}
@test "lib log: basic warning logging with BASH_IT_LOG_LEVEL_ALL" {
BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_ALL
run _log_warning "test test test"
assert_output " WARN: test test test"
}
@test "lib log: basic error logging with BASH_IT_LOG_LEVEL_ALL" {
BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_ALL
run _log_error "test test test"
assert_output "ERROR: test test test"
}
@test "lib log: basic debug logging with BASH_IT_LOG_LEVEL_WARNING" {
BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_WARNING
run _log_debug "test test test"
refute_output
}
@test "lib log: basic warning logging with BASH_IT_LOG_LEVEL_WARNING" {
BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_WARNING
run _log_warning "test test test"
assert_output " WARN: test test test"
}
@test "lib log: basic error logging with BASH_IT_LOG_LEVEL_WARNING" {
BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_WARNING
run _log_error "test test test"
assert_output "ERROR: test test test"
}
@test "lib log: basic debug logging with BASH_IT_LOG_LEVEL_ERROR" {
BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_ERROR
run _log_debug "test test test"
refute_output
}
@test "lib log: basic warning logging with BASH_IT_LOG_LEVEL_ERROR" {
BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_ERROR
run _log_warning "test test test"
refute_output
}
@test "lib log: basic error logging with BASH_IT_LOG_LEVEL_ERROR" {
BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_ERROR
run _log_error "test test test"
assert_output "ERROR: test test test"
}
@test "lib log: basic debug silent logging" {
run _log_debug "test test test"
refute_output
}
@test "lib log: basic warning silent logging" {
run _log_warning "test test test"
refute_output
}
@test "lib log: basic error silent logging" {
run _log_error "test test test"
refute_output
}