Add dirdiff to tests
This commit is contained in:
parent
017426467b
commit
d60828fc15
3 changed files with 22 additions and 20 deletions
|
@ -68,7 +68,7 @@ func restore_dir(repo *khepri.Repository, id khepri.ID, target string) error {
|
|||
|
||||
nodepath := path.Join(target, name)
|
||||
if node.Mode.IsDir() {
|
||||
err = os.MkdirAll(nodepath, 0700)
|
||||
err = os.Mkdir(nodepath, 0700)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -83,16 +83,16 @@ func restore_dir(repo *khepri.Repository, id khepri.ID, target string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
err = restore_dir(repo, node.Content, nodepath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = os.Chtimes(nodepath, node.AccessTime, node.ModTime)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = restore_dir(repo, node.Content, nodepath)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
err = restore_file(repo, node, nodepath)
|
||||
if err != nil {
|
||||
|
|
22
test/run.sh
22
test/run.sh
|
@ -3,13 +3,10 @@
|
|||
set -e
|
||||
|
||||
export khepri="${1:-khepri}"; shift
|
||||
export dirdiff="${1:-dirdiff}"; shift
|
||||
export dir=$(dirname "$0")
|
||||
export fake_data_file="${dir}/fake-data.tar.gz"
|
||||
|
||||
k() {
|
||||
"${khepri}" "$@"
|
||||
}
|
||||
|
||||
prepare() {
|
||||
export BASE="$(mktemp --tmpdir --directory khepri-testsuite-XXXXXX)"
|
||||
export KHEPRI_REPOSITORY="${BASE}/khepri-backup"
|
||||
|
@ -33,6 +30,14 @@ cleanup() {
|
|||
unset KHEPRI_REPOSITORY
|
||||
}
|
||||
|
||||
khepri() {
|
||||
"${khepri}" "$@"
|
||||
}
|
||||
|
||||
dirdiff() {
|
||||
"${dirdiff}" "$@"
|
||||
}
|
||||
|
||||
msg() {
|
||||
printf "%s: %s\n" "$(basename "$0" .sh)" "$*"
|
||||
}
|
||||
|
@ -64,7 +69,7 @@ run() {
|
|||
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
|
||||
fail khepri binary not found!
|
||||
|
@ -81,10 +86,5 @@ echo "testfiles: $testfiles"
|
|||
for testfile in "$testfiles"; do
|
||||
current=$(basename "${testfile}" .sh)
|
||||
|
||||
bash "${testfile}"
|
||||
if [ "$?" != "0" ]; then
|
||||
err "${current} failed!"
|
||||
else
|
||||
pass "${current} pass"
|
||||
fi
|
||||
bash "${testfile}" && pass "${current} pass" || err "${current} failed!"
|
||||
done
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
set -e
|
||||
|
||||
prepare
|
||||
run k backup "${BASE}/fake-data"
|
||||
run k restore "$(k list ref)" "${BASE}/fake-data-restore"
|
||||
diff -aur "${BASE}/fake-data" "${BASE}/fake-data-restore"
|
||||
run khepri backup "${BASE}/fake-data"
|
||||
run khepri restore "$(khepri list ref)" "${BASE}/fake-data-restore"
|
||||
dirdiff "${BASE}/fake-data" "${BASE}/fake-data-restore"
|
||||
cleanup
|
||||
|
|
Loading…
Reference in a new issue