Created
August 6, 2023 17:04
-
-
Save mathew-fleisch/e7b54d0ecf40ef0183869ac4b0d3ea25 to your computer and use it in GitHub Desktop.
test for cm-queue.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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