Commit e380b399 authored by Emeric Verschuur's avatar Emeric Verschuur Committed by Emeric Verschuur

Replace message functions by bashopts_log function

parent b099d64e
This diff is collapsed.
......@@ -159,7 +159,7 @@ _test_case_10() {
bashopts_declare -n simple_val -s -l value -d "Simple value" -t string -v 'val'
bashopts_parse_args --value=test
req_test_eq "$(bashopts_process_opts 2>&1)" "[WARNING] No settings file specified"
req_test_eq "$(bashopts_process_opts 2>&1)" "[WARN] No settings file specified"
}
_test_case_11() {
......@@ -168,7 +168,7 @@ _test_case_11() {
bashopts_declare -n simple_val -s -l value -d "Simple value" -t string -v 'val'
bashopts_parse_args --value=test
req_test_eq "$(bashopts_process_opts 2>&1 | grep 'WARNING')" "[WARNING] Please check the settings file"
req_test_eq "$(bashopts_process_opts 2>&1 | grep 'WARN')" "[WARN] Please check the settings file"
}
_test_case_12() {
......@@ -276,9 +276,12 @@ _test_case_18() {
bashopts_declare -n a_boolean_value -l boolean -m set -d "A boolean value" -t boolean -i
bashopts_parse_args
req_test_eq "$(bashopts_process_opts 2>&1 >/dev/null <<< "tru")" "[ERROR] 'tru' is not a valid boolean value"
req_test_eq "$(bashopts_process_opts 2>&1 >/dev/null <<< "fa")" "[ERROR] 'fa' is not a valid boolean value"
req_test_eq "$(bashopts_process_opts 2>&1 >/dev/null <<< "5")" "[ERROR] '5' is not a valid boolean value"
req_test_eq "$(bashopts_process_opts 2>&1 >/dev/null <<< "tru" \
| grep '^\[ERR')" "[ERRO] 'tru' is not a valid boolean value"
req_test_eq "$(bashopts_process_opts 2>&1 >/dev/null <<< "fa" \
| grep '^\[ERR')" "[ERRO] 'fa' is not a valid boolean value"
req_test_eq "$(bashopts_process_opts 2>&1 >/dev/null <<< "5" \
| grep '^\[ERR')" "[ERRO] '5' is not a valid boolean value"
}
_test_case_19() {
......@@ -297,7 +300,7 @@ is_eq_to_null() {
echo "$1"
return 0
fi
bashopts_error "Not equal to NULL"
bashopts_log E "Not equal to NULL"
return 1
}
......@@ -309,11 +312,9 @@ _test_case_20() {
bashopts_parse_args
bashopts_process_opts
req_test_eq "$(echo "$(bashopts_process_option -n value -k is_eq_to_null -r 2>&1 > /dev/null <<< "na")" \
| grep '\[ERROR\] Not equal to NULL' \
| head -n 1 || true)" '[ERROR] Not equal to NULL'
| grep '^\[ERR' | tail -n 1 || true)" '[ERRO] Not equal to NULL'
req_test_eq "$(echo "$(bashopts_process_option -n value -k is_eq_to_null -r 2>&1 > /dev/null <<< "()")" \
| grep '\[ERROR\] At least one value required' \
| head -n 1 || true)" '[ERROR] At least one value required'
| grep '^\[ERR' | tail -n 1 || true)" '[ERRO] At least one value required'
bashopts_process_option -n value -k is_eq_to_null -r > /dev/null 2>&1 <<< "NULL"
}
......@@ -325,8 +326,7 @@ _test_case_21() {
bashopts_parse_args -n
bashopts_process_opts
req_test_eq "$(echo "$(bashopts_process_option -n value -k is_not_empty -r 2>&1 > /dev/null)" \
| grep '\[ERROR\] At least one value required' \
| head -n 1)" '[ERROR] At least one value required'
| grep '^\[ERR' | head -n 1)" '[ERRO] At least one value required'
}
_test_case_22() {
......@@ -388,7 +388,7 @@ _test_case_27() {
bashopts_setup -n "$0" -d "Test case $0"
req_test_eq "$(bashopts_declare -n value -l value -d "A str value" -t string -r -v "test" 2>&1)" \
"[ERROR] bashopts_declare: -r and -v options cannot be activated at the same time"
"[CRIT] bashopts_declare: -r and -v options cannot be activated at the same time"
}
_test() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment