mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-11 13:40:07 +00:00
More tests for get_var
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
plan 3
|
plan 8
|
||||||
|
|
||||||
TMPDIR="$TEST_TMPDIR"
|
TMPDIR="$TEST_TMPDIR"
|
||||||
PATH="$PATH:$PERCONA_TOOLKIT_SANDBOX/bin"
|
PATH="$PATH:$PERCONA_TOOLKIT_SANDBOX/bin"
|
||||||
@@ -26,3 +26,35 @@ is \
|
|||||||
"$(get_var "test::1" "$p")" \
|
"$(get_var "test::1" "$p")" \
|
||||||
"abcdef" \
|
"abcdef" \
|
||||||
"get_var works if the 'key' has colons"
|
"get_var works if the 'key' has colons"
|
||||||
|
|
||||||
|
|
||||||
|
echo "1234/567 qwerty" > "$p"
|
||||||
|
is \
|
||||||
|
"$(get_var "1234/567" "$p")" \
|
||||||
|
"qwerty" \
|
||||||
|
"get_var works if the 'key' has a dash in it"
|
||||||
|
|
||||||
|
|
||||||
|
echo ".* some_new_value" >> "$p"
|
||||||
|
is \
|
||||||
|
"$(get_var ".*" "$p")" \
|
||||||
|
"some_new_value" \
|
||||||
|
"get_var treats the variable as a literal, not a regex"
|
||||||
|
|
||||||
|
if get_var "definitely_does_not_exist" "$p" 1>/dev/null ; then
|
||||||
|
pass "get_var always returns true, even for variables that don't exist"
|
||||||
|
else
|
||||||
|
fail "get_var should always return true"
|
||||||
|
fi
|
||||||
|
|
||||||
|
samples="$PERCONA_TOOLKIT_BRANCH/t/pt-mysql-summary/samples"
|
||||||
|
|
||||||
|
is \
|
||||||
|
"$(get_var "table_open_cache" "$samples/temp002/mysql-variables")" \
|
||||||
|
"400" \
|
||||||
|
"get_var works on a variables dump"
|
||||||
|
|
||||||
|
is \
|
||||||
|
"$(get_var "Open_tables" "$samples/temp002/mysql-status")" \
|
||||||
|
"40" \
|
||||||
|
"get_var works on a status dump"
|
||||||
|
@@ -124,6 +124,18 @@ plan() {
|
|||||||
# The following subs are for the test files to call.
|
# The following subs are for the test files to call.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
pass() {
|
||||||
|
local reason="${1:-""}"
|
||||||
|
|
||||||
|
result 0 "$reason"
|
||||||
|
}
|
||||||
|
|
||||||
|
fail() {
|
||||||
|
local reason="${1:-""}"
|
||||||
|
|
||||||
|
result 1 "$reason"
|
||||||
|
}
|
||||||
|
|
||||||
skip() {
|
skip() {
|
||||||
local skip="$1"
|
local skip="$1"
|
||||||
local number_of_tests="$2"
|
local number_of_tests="$2"
|
||||||
|
Reference in New Issue
Block a user