mirror of
https://github.com/offen/docker-volume-backup.git
synced 2026-04-18 06:55:36 +02:00
Ensure end time is recorded for unsuccessful runs too (#62)
* Ensure end time is also recorded for unsuccessful runs * Clean up integration tests
This commit is contained in:
@@ -10,49 +10,43 @@ docker-compose up -d
|
||||
sleep 5
|
||||
|
||||
GOTIFY_TOKEN=$(curl -sSLX POST -H 'Content-Type: application/json' -d '{"name":"test"}' http://admin:custom@localhost:8080/application | jq -r '.token')
|
||||
|
||||
docker-compose down
|
||||
|
||||
GOTIFY_TOKEN=$GOTIFY_TOKEN docker-compose up -d
|
||||
|
||||
echo "[TEST:INFO] Set up Gotify application using token $GOTIFY_TOKEN"
|
||||
|
||||
docker-compose exec backup backup
|
||||
|
||||
tar -xf ./local/test.tar.gz -C /tmp && test -f /tmp/backup/app_data/offen.db
|
||||
echo "[TEST:PASS] Found relevant files in untared local backup."
|
||||
|
||||
if [ "$(docker-compose ps -q | wc -l)" != "3" ]; then
|
||||
echo "[TEST:FAIL] Expected all containers to be running post backup, instead seen:"
|
||||
docker-compose ps
|
||||
NUM_MESSAGES=$(curl -sSL http://admin:custom@localhost:8080/message | jq -r '.messages | length')
|
||||
if [ "$NUM_MESSAGES" != 0 ]; then
|
||||
echo "[TEST:FAIL] Expected no notifications to be sent when not configured"
|
||||
exit 1
|
||||
fi
|
||||
echo "[TEST:PASS] No notifications were sent when not configured."
|
||||
|
||||
echo "[TEST:PASS] All containers running post backup."
|
||||
docker-compose down
|
||||
|
||||
MESSAGE=$(curl -sSL http://admin:custom@localhost:8080/message | jq -r '.messages[0]')
|
||||
NOTIFICATION_URLS="gotify://gotify/${GOTIFY_TOKEN}?disableTLS=true" docker-compose up -d
|
||||
|
||||
docker-compose exec backup backup
|
||||
|
||||
case "$MESSAGE" in
|
||||
*"Successful test run, yay!"*)
|
||||
echo "[TEST:PASS] Custom notification title was used"
|
||||
;;
|
||||
*)
|
||||
echo "[TEST:FAIL] Expected custom title to be used in notification, instead seen:"
|
||||
echo $MESSAGE
|
||||
NUM_MESSAGES=$(curl -sSL http://admin:custom@localhost:8080/message | jq -r '.messages | length')
|
||||
if [ "$NUM_MESSAGES" != 1 ]; then
|
||||
echo "[TEST:FAIL] Expected one notifications to be sent when configured"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
echo "[TEST:PASS] Correct number of notifications were sent when configured."
|
||||
|
||||
case "$MESSAGE" in
|
||||
*"Backing up /tmp/test.tar.gz succeeded."*)
|
||||
echo "[TEST:PASS] Custom notification body was used"
|
||||
;;
|
||||
*)
|
||||
echo "[TEST:FAIL] Expected custom body to be used in notification, instead seen:"
|
||||
echo $MESSAGE
|
||||
MESSAGE_TITLE=$(curl -sSL http://admin:custom@localhost:8080/message | jq -r '.messages[0].title')
|
||||
MESSAGE_BODY=$(curl -sSL http://admin:custom@localhost:8080/message | jq -r '.messages[0].message')
|
||||
|
||||
if [ "$MESSAGE_TITLE" != "Successful test run, yay!" ]; then
|
||||
echo "[TEST:FAIL] Unexpected notification title $MESSAGE_TITLE"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
echo "[TEST:PASS] Custom notification title was used."
|
||||
|
||||
if [ "$MESSAGE_BODY" != "Backing up /tmp/test.tar.gz succeeded." ]; then
|
||||
echo "[TEST:FAIL] Unexpected notification body $MESSAGE_BODY"
|
||||
exit 1
|
||||
fi
|
||||
echo "[TEST:PASS] Custom notification body was used."
|
||||
|
||||
docker-compose down --volumes
|
||||
|
||||
Reference in New Issue
Block a user