source "${OET_PATH}/libs/locallibs/common_lib.sh"
function pre_test() {
LOG_INFO "Start environmental preparation."
DNF_INSTALL "python-tabulate"
echo -e "Name\tAge\tCity\nAlice\t30\tNew York\nBob\t25\tLos Angeles" > ./test_data.txt
LOG_INFO "End of environmental preparation!"
}
function run_test() {
LOG_INFO "Start to run test."
tabulate ./test_data.txt
CHECK_RESULT $? 0 0 "tabulate default format failed"
for fmt in plain simple grid fancy_grid pipe orgtbl rst mediawiki html latex latex_raw latex_booktabs latex_longtable tsv; do
tabulate -f $fmt ./test_data.txt
CHECK_RESULT $? 0 0 "tabulate format $fmt failed"
done
tabulate -s '\t' ./test_data.txt
CHECK_RESULT $? 0 0 "tabulate custom separator failed"
tabulate -1 ./test_data.txt
CHECK_RESULT $? 0 0 "tabulate header failed"
tabulate -o ./output.txt ./test_data.txt
CHECK_RESULT $? 0 0 "tabulate output to file failed"
LOG_INFO "End of the test."
}
function post_test() {
LOG_INFO "start environment cleanup."
DNF_REMOVE "python-tabulate"
rm -f ./test_data.txt ./output.txt
LOG_INFO "End of environment cleanup!"
}
main "$@"