added shunit2 tests for parameter validation
parent
5571785ad1
commit
958b842e54
@ -1,9 +1,15 @@
|
||||
pipeline:
|
||||
|
||||
docker:
|
||||
image: plugins/docker
|
||||
repo: bunix42/drone-sendxmpp
|
||||
tags:
|
||||
- 0.0.1
|
||||
- latest
|
||||
secrets: [ docker_username, docker_password ]
|
||||
test:
|
||||
image: alpine
|
||||
commands:
|
||||
- cd test
|
||||
- ./sendxmpp_parameter_test.sh
|
||||
|
||||
# docker:
|
||||
# image: plugins/docker
|
||||
# repo: bunix42/drone-sendxmpp
|
||||
# tags:
|
||||
# - 0.0.1
|
||||
# - latest
|
||||
# secrets: [ docker_username, docker_password ]
|
||||
|
@ -0,0 +1,77 @@
|
||||
# !/bin/sh
|
||||
|
||||
setUp() {
|
||||
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 1 $?
|
||||
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 1 $?
|
||||
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 1 $?
|
||||
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
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue