From 5263f5ac59ced0db302bc99beb0f00359749508a Mon Sep 17 00:00:00 2001 From: Noah Gorny Date: Tue, 23 Jun 2020 15:59:14 +0300 Subject: [PATCH] test: Add lib log basic testing --- test/lib/log.bats | 79 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 test/lib/log.bats diff --git a/test/lib/log.bats b/test/lib/log.bats new file mode 100644 index 00000000..da31a9b5 --- /dev/null +++ b/test/lib/log.bats @@ -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 +}