1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
drone-sendxmpp/test/sendxmpp_parameter_test.sh

81 lines
1.9 KiB
Bash

# !/bin/sh
setUp() {
# if sendxmpp is present command will fail with err code 1 because of invalid domain
# otherwise it will ultimatly fail with return code 127 aka command not found
command -v sendxmpp > /dev/null && export EXPECTED_RETURN_CODE=1 || export EXPECTED_RETURN_CODE=127
export PLUGIN_USERNAME="username"
export PLUGIN_PASSWORD="password"
export PLUGIN_JSERVER="server.invalid"
export PLUGIN_RECIPIENT="foo@bar.invalid"
}
tearDown() {
unset PLUGIN_USERNAME
unset PLUGIN_PASSWORD
unset PLUGIN_JSERVER
unset PLUGIN_RECIPIENT
unset SENDXMPP_USERNAME
unset SENDXMPP_PASSWORD
}
testAllOk() {
stdout=$( ../sendxmpp.sh 2> /dev/null )
assertEquals $EXPECTED_RETURN_CODE $?
assertTrue "[ -z "$stdout" ]"
}
testMissingUsernameAndUsernameSecret() {
unset PLUGIN_USERNAME
unset SENDXMPP_USERNAME
stdout=$( ../sendxmpp.sh 2> /dev/null )
assertEquals 123 $?
assertEquals "missing username or sendxmpp_username secret" "$stdout"
}
testUsernameSecretSet() {
unset PLUGIN_USERNAME
export SENDXMPP_USERNAME="secretusername"
stdout=$( ../sendxmpp.sh 2> /dev/null )
assertEquals $EXPECTED_RETURN_CODE $?
assertTrue "[ -z "$stdout" ]"
}
testMissingPasswordAndPasswordSecret() {
unset PLUGIN_PASSWORD
unset SENDXMPP_PASSWORD
stdout=$( ../sendxmpp.sh 2> /dev/null )
assertEquals 123 $?
assertEquals "missing password or sendxmpp_password secret" "$stdout"
}
testPasswordSecretSet() {
unset PLUGIN_PASSWORD
export SENDXMPP_PASSWORD="secretpassword"
stdout=$( ../sendxmpp.sh 2> /dev/null )
assertEquals $EXPECTED_RETURN_CODE $?
assertTrue "[ -z "$stdout" ]"
}
testMissingJserver() {
unset PLUGIN_JSERVER
stdout=$( ../sendxmpp.sh 2> /dev/null )
assertEquals 123 $?
assertEquals "missing jserver" "$stdout"
}
testMissingRecipient() {
unset PLUGIN_RECIPIENT
stdout=$( ../sendxmpp.sh 2> /dev/null )
assertEquals 123 $?
assertEquals "missing recipient" "$stdout"
}
. ./shunit2