Skip to content

Instantly share code, notes, and snippets.

@mathew-fleisch
Created August 6, 2023 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mathew-fleisch/e7b54d0ecf40ef0183869ac4b0d3ea25 to your computer and use it in GitHub Desktop.
Save mathew-fleisch/e7b54d0ecf40ef0183869ac4b0d3ea25 to your computer and use it in GitHub Desktop.
test for cm-queue.sh
#!/bin/bash
# testing cm-queue.sh from: https://gist.github.com/mathew-fleisch/9743d9801cc2ce3bd6aa678b49cd8ea6
ns=default
cmqueue=test-queue
cmkey=queue
function setup_test() {
echo "Setting up queue..."
./cm-queue.sh $ns $cmqueue $cmkey delete \
&& echo && ./cm-queue.sh $ns $cmqueue $cmkey append test2 \
&& echo && ./cm-queue.sh $ns $cmqueue $cmkey append test3 \
&& echo && ./cm-queue.sh $ns $cmqueue $cmkey prepend test1 \
&& echo && ./cm-queue.sh $ns $cmqueue $cmkey prepend test0
echo
echo "Setup complete."
}
echo
echo "---------------------------"
echo "ConfigMap Queue Tests..."
echo "---------------------------" && echo
setup_test
echo "---------------------------"
echo
test_01=$(./cm-queue.sh $ns $cmqueue $cmkey getall | tr '\n' ' ')
echo "expect: '$test_01' == 'test0 test1 test2 test3'"
if [ "$test_01" != "test0 test1 test2 test3" ]; then
echo
echo "πŸ”΄ prepend/append/getall test failed!"
echo "'$test_01' != 'test0 test1 test2 test3'"
exit 1
else
echo
echo "🟒 prepend/append/getall test passed!"
echo
echo "---------------------------"
fi
test_02_00=$(./cm-queue.sh $ns $cmqueue $cmkey shift)
echo "expect: '$test_02_00' == 'test0'"
if [ "$test_02_00" != "test0" ]; then
echo
echo "πŸ”΄ shift[00] test failed!"
echo "'$test_02_00' != 'test0'"
exit 1
else
echo
echo "🟒 shift[00] test passed!"
echo
echo "---------------------------"
fi
test_02_01=$(./cm-queue.sh $ns $cmqueue $cmkey shift)
echo "expect: '$test_02_01' == 'test1'"
if [ "$test_02_01" != "test1" ]; then
echo
echo "πŸ”΄ shift[01] test failed!"
echo "'$test_02_01' != 'test1'"
exit 1
else
echo
echo "🟒 shift[01] test passed!"
echo
echo "---------------------------"
fi
test_02_02=$(./cm-queue.sh $ns $cmqueue $cmkey shift)
echo "expect: '$test_02_02' == 'test2'"
if [ "$test_02_02" != "test2" ]; then
echo
echo "πŸ”΄ shift[02] test failed!"
echo "'$test_02_02' != 'test2'"
exit 1
else
echo
echo "🟒 shift[02] test passed!"
echo
echo "---------------------------"
fi
test_02_03=$(./cm-queue.sh $ns $cmqueue $cmkey shift)
echo "expect: '$test_02_03' == 'test3'"
if [ "$test_02_03" != "test3" ]; then
echo
echo "πŸ”΄ shift[03] test failed!"
echo "'$test_02_03' != 'test3'"
exit 1
else
echo
echo "🟒 shift[03] test passed!"
echo
echo "---------------------------"
fi
setup_test
echo
echo "---------------------------"
echo
test_03_00=$(./cm-queue.sh $ns $cmqueue $cmkey pop)
echo "expect: '$test_03_00' == 'test3'"
if [ "$test_03_00" != "test3" ]; then
echo
echo "πŸ”΄ pop[00] test failed!"
echo "'$test_03_00' != 'test3'"
exit 1
else
echo
echo "🟒 pop[00] test passed!"
echo
echo "---------------------------"
fi
test_03_01=$(./cm-queue.sh $ns $cmqueue $cmkey pop)
echo "expect: '$test_03_01' == 'test2'"
if [ "$test_03_01" != "test2" ]; then
echo
echo "πŸ”΄ pop[01] test failed!"
echo "'$test_03_01' != 'test2'"
exit 1
else
echo
echo "🟒 pop[01] test passed!"
echo
echo "---------------------------"
fi
test_03_02=$(./cm-queue.sh $ns $cmqueue $cmkey pop)
echo "expect: '$test_03_02' == 'test1'"
if [ "$test_03_02" != "test1" ]; then
echo
echo "πŸ”΄ pop[02] test failed!"
echo "'$test_03_02' != 'test1'"
exit 1
else
echo
echo "🟒 pop[02] test passed!"
echo
echo "---------------------------"
fi
test_03_03=$(./cm-queue.sh $ns $cmqueue $cmkey pop)
echo "expect: '$test_03_03' == 'test0'"
if [ "$test_03_03" != "test0" ]; then
echo
echo "πŸ”΄ pop[03] test failed!"
echo "'$test_03_03' != 'test0'"
exit 1
else
echo
echo "🟒 pop[03] test passed!"
echo
echo "---------------------------"
fi
echo
echo "🟒 All tests passed!"
echo
echo "---------------------------"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment