Skip to content

Commit

Permalink
Merge branch 'master' into lildude/clean-old-nodes-on-restore
Browse files Browse the repository at this point in the history
  • Loading branch information
lildude committed May 21, 2018
2 parents b74d601 + b47e96f commit 184156d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion share/github-backup-utils/ghe-restore-snapshot-path
Expand Up @@ -23,7 +23,8 @@ if [ "$GHE_RESTORE_SNAPSHOT" = "current" ]; then
fi

# Bail out if we don't have a good snapshot.
if [ ! -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" ]; then
if [ -z "$GHE_RESTORE_SNAPSHOT" ] || [ ! -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" ]; then
: "${GHE_RESTORE_SNAPSHOT:=current}"
echo "Error: Snapshot '$GHE_RESTORE_SNAPSHOT' doesn't exist." 1>&2
exit 1
fi
Expand Down
22 changes: 22 additions & 0 deletions test/test-ghe-restore.sh
Expand Up @@ -10,6 +10,28 @@ setup_test_data "$GHE_DATA_DIR/1"
# Make the current symlink
ln -s 1 "$GHE_DATA_DIR/current"

begin_test "ghe-restore-snapshot-path reports an error when current symlink doesn't exist"
(
set -e
rm "$GHE_DATA_DIR/current"

ghe-restore-snapshot-path > "$TRASHDIR/restore-out" 2>&1 || true
ln -s 1 "$GHE_DATA_DIR/current"
grep -q "Error: Snapshot 'current' doesn't exist." "$TRASHDIR/restore-out"
)
end_test

begin_test "ghe-restore-snapshot-path reports an error when specified snapshot doesn't exist"
(
set -e
rm "$GHE_DATA_DIR/current"

ghe-restore-snapshot-path foo > "$TRASHDIR/restore-out" 2>&1 || true
ln -s 1 "$GHE_DATA_DIR/current"
grep -q "Error: Snapshot 'foo' doesn't exist." "$TRASHDIR/restore-out"
)
end_test

begin_test "ghe-restore into configured vm"
(
set -e
Expand Down

0 comments on commit 184156d

Please sign in to comment.