mirror of
https://github.com/gilbertchen/duplicacy
synced 2025-12-06 00:03:38 +00:00
Remove logging statement; refactor test scripts
This commit is contained in:
103
integration_tests/test_functions.sh
Normal file
103
integration_tests/test_functions.sh
Normal file
@@ -0,0 +1,103 @@
|
||||
#!/bin/bash
|
||||
|
||||
get_abs_filename() {
|
||||
# $1 : relative filename
|
||||
echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
|
||||
}
|
||||
|
||||
pushd () {
|
||||
command pushd "$@" > /dev/null
|
||||
}
|
||||
|
||||
popd () {
|
||||
command popd "$@" > /dev/null
|
||||
}
|
||||
|
||||
|
||||
# Functions used to create integration tests suite
|
||||
|
||||
DUPLICACY=$(get_abs_filename ../duplicacy_main)
|
||||
|
||||
# Base directory where test repositories will be created
|
||||
TEST_ZONE=$HOME/DUPLICACY_TEST_ZONE
|
||||
# Test Repository
|
||||
TEST_REPO=$TEST_ZONE/TEST_REPO
|
||||
|
||||
# Storage for test ( For now, only local path storage is supported by test suite)
|
||||
TEST_STORAGE=$TEST_ZONE/TEST_STORAGE
|
||||
|
||||
# Preference directory ( for testing the -pref-dir option)
|
||||
DUPLICACY_PREF_DIR=$TEST_ZONE/TEST_DUPLICACY_PREF_DIR
|
||||
|
||||
# Scratch pad for testing restore
|
||||
TEST_RESTORE_POINT=$TEST_ZONE/RESTORE_POINT
|
||||
|
||||
# Make sure $TEST_ZONE is in know state
|
||||
|
||||
|
||||
|
||||
function fixture()
|
||||
{
|
||||
# clean TEST_RESTORE_POINT
|
||||
rm -rf $TEST_RESTORE_POINT
|
||||
mkdir -p $TEST_RESTORE_POINT
|
||||
|
||||
# clean TEST_STORAGE
|
||||
rm -rf $TEST_STORAGE
|
||||
mkdir -p $TEST_STORAGE
|
||||
|
||||
# clean TEST_DOT_DUPLICACY
|
||||
rm -rf $DUPLICACY_PREF_DIR
|
||||
mkdir -p $DUPLICACY_PREF_DIR
|
||||
|
||||
# Create test repository
|
||||
rm -rf ${TEST_REPO}
|
||||
mkdir -p ${TEST_REPO}
|
||||
pushd ${TEST_REPO}
|
||||
echo "file1" > file1
|
||||
mkdir dir1
|
||||
echo "file2" > dir1/file2
|
||||
popd
|
||||
}
|
||||
|
||||
function init_repo()
|
||||
{
|
||||
pushd ${TEST_REPO}
|
||||
${DUPLICACY} init integration-tests $TEST_STORAGE
|
||||
${DUPLICACY} backup
|
||||
popd
|
||||
|
||||
}
|
||||
|
||||
function init_repo_pref_dir()
|
||||
{
|
||||
pushd ${TEST_REPO}
|
||||
${DUPLICACY} init -pref-dir "${DUPLICACY_PREF_DIR}" integration-tests ${TEST_STORAGE}
|
||||
${DUPLICACY} backup
|
||||
popd
|
||||
|
||||
}
|
||||
|
||||
function add_file()
|
||||
{
|
||||
FILE_NAME=$1
|
||||
pushd ${TEST_REPO}
|
||||
echo ${FILE_NAME} > "${FILE_NAME}"
|
||||
popd
|
||||
}
|
||||
|
||||
|
||||
function backup()
|
||||
{
|
||||
pushd ${TEST_REPO}
|
||||
${DUPLICACY} backup
|
||||
popd
|
||||
}
|
||||
|
||||
|
||||
function restore()
|
||||
{
|
||||
pushd ${TEST_REPO}
|
||||
${DUPLICACY} restore -r 2 -delete
|
||||
popd
|
||||
}
|
||||
Reference in New Issue
Block a user