devstack/tests/test_functions.sh
Sean Dague 537532931d Make changes such that -o nounset runs
This makes a bunch of variable cleanups that will let -o nounset
function, for the time being we hide nounset behind another setting
variable so that it's not on by default.

Because this is bash, and things are only executed on demand, this
probably only works in the config it was run in. Expect cleaning up
all the paths to be something that takes quite a while.

This also includes a new set of unit tests around the trueorfalse
function, because my change in how it worked, didn't. Tests are good
m'kay.

Change-Id: I71a896623ea9e1f042a73dc0678ce85acf0dc87d
2015-01-15 13:06:14 -05:00

35 lines
830 B
Bash
Executable File

#!/usr/bin/env bash
# Tests for DevStack meta-config functions
TOP=$(cd $(dirname "$0")/.. && pwd)
# Import common functions
source $TOP/functions
source $TOP/tests/unittest.sh
function test_truefalse {
local one=1
local captrue=True
local lowtrue=true
local abrevtrue=t
local zero=0
local capfalse=False
local lowfalse=false
local abrevfalse=f
for against in True False; do
for name in one captrue lowtrue abrevtrue; do
assert_equal "True" $(trueorfalse $against $name) "\$(trueorfalse $against $name)"
done
done
for against in True False; do
for name in zero capfalse lowfalse abrevfalse; do
assert_equal "False" $(trueorfalse $against $name) "\$(trueorfalse $against $name)"
done
done
}
test_truefalse
report_results