mirror of
https://github.com/octoleo/restic.git
synced 2024-12-22 02:48:55 +00:00
Add dirdiff to tests
This commit is contained in:
parent
017426467b
commit
d60828fc15
@ -68,7 +68,7 @@ func restore_dir(repo *khepri.Repository, id khepri.ID, target string) error {
|
|||||||
|
|
||||||
nodepath := path.Join(target, name)
|
nodepath := path.Join(target, name)
|
||||||
if node.Mode.IsDir() {
|
if node.Mode.IsDir() {
|
||||||
err = os.MkdirAll(nodepath, 0700)
|
err = os.Mkdir(nodepath, 0700)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -83,16 +83,16 @@ func restore_dir(repo *khepri.Repository, id khepri.ID, target string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = restore_dir(repo, node.Content, nodepath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
err = os.Chtimes(nodepath, node.AccessTime, node.ModTime)
|
err = os.Chtimes(nodepath, node.AccessTime, node.ModTime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = restore_dir(repo, node.Content, nodepath)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
err = restore_file(repo, node, nodepath)
|
err = restore_file(repo, node, nodepath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
22
test/run.sh
22
test/run.sh
@ -3,13 +3,10 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
export khepri="${1:-khepri}"; shift
|
export khepri="${1:-khepri}"; shift
|
||||||
|
export dirdiff="${1:-dirdiff}"; shift
|
||||||
export dir=$(dirname "$0")
|
export dir=$(dirname "$0")
|
||||||
export fake_data_file="${dir}/fake-data.tar.gz"
|
export fake_data_file="${dir}/fake-data.tar.gz"
|
||||||
|
|
||||||
k() {
|
|
||||||
"${khepri}" "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
prepare() {
|
prepare() {
|
||||||
export BASE="$(mktemp --tmpdir --directory khepri-testsuite-XXXXXX)"
|
export BASE="$(mktemp --tmpdir --directory khepri-testsuite-XXXXXX)"
|
||||||
export KHEPRI_REPOSITORY="${BASE}/khepri-backup"
|
export KHEPRI_REPOSITORY="${BASE}/khepri-backup"
|
||||||
@ -33,6 +30,14 @@ cleanup() {
|
|||||||
unset KHEPRI_REPOSITORY
|
unset KHEPRI_REPOSITORY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
khepri() {
|
||||||
|
"${khepri}" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
dirdiff() {
|
||||||
|
"${dirdiff}" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
msg() {
|
msg() {
|
||||||
printf "%s: %s\n" "$(basename "$0" .sh)" "$*"
|
printf "%s: %s\n" "$(basename "$0" .sh)" "$*"
|
||||||
}
|
}
|
||||||
@ -64,7 +69,7 @@ run() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
export -f k prepare cleanup msg debug pass err fail run
|
export -f khepri dirdiff prepare cleanup msg debug pass err fail run
|
||||||
|
|
||||||
if [ ! -x "$khepri" ]; then
|
if [ ! -x "$khepri" ]; then
|
||||||
fail khepri binary not found!
|
fail khepri binary not found!
|
||||||
@ -81,10 +86,5 @@ echo "testfiles: $testfiles"
|
|||||||
for testfile in "$testfiles"; do
|
for testfile in "$testfiles"; do
|
||||||
current=$(basename "${testfile}" .sh)
|
current=$(basename "${testfile}" .sh)
|
||||||
|
|
||||||
bash "${testfile}"
|
bash "${testfile}" && pass "${current} pass" || err "${current} failed!"
|
||||||
if [ "$?" != "0" ]; then
|
|
||||||
err "${current} failed!"
|
|
||||||
else
|
|
||||||
pass "${current} pass"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
|
set -e
|
||||||
|
|
||||||
prepare
|
prepare
|
||||||
run k backup "${BASE}/fake-data"
|
run khepri backup "${BASE}/fake-data"
|
||||||
run k restore "$(k list ref)" "${BASE}/fake-data-restore"
|
run khepri restore "$(khepri list ref)" "${BASE}/fake-data-restore"
|
||||||
diff -aur "${BASE}/fake-data" "${BASE}/fake-data-restore"
|
dirdiff "${BASE}/fake-data" "${BASE}/fake-data-restore"
|
||||||
cleanup
|
cleanup
|
||||||
|
Loading…
Reference in New Issue
Block a user