test: add a test case to test rclone flags valid
This commit is contained in:
@@ -90,6 +90,7 @@ function test_result() {
|
||||
|
||||
. tests/units/env-priority/test.sh
|
||||
. tests/units/check-rclone-config-exists/test.sh
|
||||
. tests/units/check-rclone-flags-valid/test.sh
|
||||
. tests/units/check-rclone-connection-initializing/test.sh
|
||||
. tests/units/backup-zip-file/test.sh
|
||||
. tests/units/backup-7z-file/test.sh
|
||||
|
||||
@@ -19,9 +19,8 @@ function prepare() {
|
||||
mkdir -p "${TEST_OUTPUT_DIR}" "${TEST_CONFIG_DIR}"
|
||||
}
|
||||
|
||||
function start() {
|
||||
echo ""
|
||||
}
|
||||
# function start() {
|
||||
# }
|
||||
|
||||
function test() {
|
||||
color blue "Testing..."
|
||||
@@ -50,7 +49,7 @@ function cleanup() {
|
||||
}
|
||||
|
||||
prepare
|
||||
start
|
||||
# start
|
||||
test
|
||||
cleanup
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Using non-existent flags with Rclone will throw an exception and exit.
|
||||
#
|
||||
# This test case ensures the verification method works correctly by triggering the error message.
|
||||
|
||||
TEST_NAME="check-rclone-flags-valid"
|
||||
TEST_OUTPUT_DIR="$(pwd)/${OUTPUT_DIR}/${TEST_NAME}"
|
||||
|
||||
PASSWORD="43ef5fec-292d-4f9a-ab97-34f622deb462"
|
||||
|
||||
FAILED_NUM=0
|
||||
|
||||
color yellow "Starting test case \"${TEST_NAME}\""
|
||||
|
||||
function prepare() {
|
||||
mkdir -p "${TEST_OUTPUT_DIR}"
|
||||
}
|
||||
|
||||
# function start() {
|
||||
# }
|
||||
|
||||
function test() {
|
||||
color blue "Testing..."
|
||||
|
||||
FOUND_MESSAGE_COUNT=$(docker run --rm \
|
||||
--mount "type=bind,source=${TEST_OUTPUT_DIR},target=${REMOTE_DIR}" \
|
||||
-e "RCLONE_REMOTE_DIR=${REMOTE_DIR}" \
|
||||
-e "RCLONE_GLOBAL_FLAG=-v --non-existent" \
|
||||
-e "ZIP_PASSWORD=${PASSWORD}" \
|
||||
-e "BACKUP_FILE_SUFFIX=test" \
|
||||
"${DOCKER_IMAGE}" \
|
||||
backup | grep -c "illegal rclone global flags")
|
||||
|
||||
if [[ "${FOUND_MESSAGE_COUNT}" -ne 1 ]]; then
|
||||
((FAILED_NUM++))
|
||||
fi
|
||||
}
|
||||
|
||||
function cleanup() {
|
||||
sudo rm -rf "${TEST_OUTPUT_DIR}"
|
||||
|
||||
unset TEST_OUTPUT_DIR
|
||||
unset PASSWORD
|
||||
unset FOUND_MESSAGE_COUNT
|
||||
}
|
||||
|
||||
prepare
|
||||
# start
|
||||
test
|
||||
cleanup
|
||||
|
||||
test_result "${TEST_NAME}" "${FAILED_NUM}"
|
||||
Reference in New Issue
Block a user