e2e: move err tests and add bad-branch

This commit is contained in:
Tim Hockin 2022-08-21 15:22:41 -07:00
parent e1774e223c
commit fcb577b9fb
No known key found for this signature in database
1 changed files with 52 additions and 26 deletions

View File

@ -284,32 +284,6 @@ function e2e::sync_head_once_root_flag_has_symlink() {
assert_file_eq "$ROOT"/link/file "$FUNCNAME"
}
##############################################
# Test non-zero exit
##############################################
function e2e::error_non_zero_exit() {
echo "$FUNCNAME" > "$REPO"/file
git -C "$REPO" commit -qam "$FUNCNAME"
(
set +o errexit
GIT_SYNC \
--one-time \
--repo="file://$REPO" \
--branch="$MAIN_BRANCH" \
--rev=does-not-exit \
--root="$ROOT" \
--link="link" \
>> "$1" 2>&1
RET=$?
if [[ "$RET" != 1 ]]; then
fail "expected exit code 1, got $RET"
fi
assert_file_absent "$ROOT"/link
assert_file_absent "$ROOT"/link/file
)
}
##############################################
# Test HEAD one-time when root is under a git repo
##############################################
@ -406,6 +380,58 @@ function e2e::sync_subdir_link() {
assert_file_eq "$ROOT"/other/dir/link/file "$FUNCNAME"
}
##############################################
# Test non-zero exit with a bad branch
##############################################
function e2e::bad_branch_non_zero_exit() {
echo "$FUNCNAME" > "$REPO"/file
git -C "$REPO" commit -qam "$FUNCNAME"
(
set +o errexit
GIT_SYNC \
--one-time \
--repo="file://$REPO" \
--branch="does-not-exist" \
--rev="HEAD" \
--root="$ROOT" \
--link="link" \
>> "$1" 2>&1
RET=$?
if [[ "$RET" != 1 ]]; then
fail "expected exit code 1, got $RET"
fi
assert_file_absent "$ROOT"/link
assert_file_absent "$ROOT"/link/file
)
}
##############################################
# Test non-zero exit with a bad rev
##############################################
function e2e::bad_rev_non_zero_exit() {
echo "$FUNCNAME" > "$REPO"/file
git -C "$REPO" commit -qam "$FUNCNAME"
(
set +o errexit
GIT_SYNC \
--one-time \
--repo="file://$REPO" \
--branch="$MAIN_BRANCH" \
--rev=does-not-exit \
--root="$ROOT" \
--link="link" \
>> "$1" 2>&1
RET=$?
if [[ "$RET" != 1 ]]; then
fail "expected exit code 1, got $RET"
fi
assert_file_absent "$ROOT"/link
assert_file_absent "$ROOT"/link/file
)
}
##############################################
# Test default-branch syncing
##############################################