Add repo-sync test

This commit is contained in:
sed-i 2022-02-25 03:46:37 -05:00
parent 4ca7832b0f
commit 9780b620c0
1 changed files with 39 additions and 0 deletions

View File

@ -411,6 +411,45 @@ function e2e::readlink() {
assert_link_eq "$ROOT"/link $(git -C "$REPO" rev-parse HEAD) assert_link_eq "$ROOT"/link $(git -C "$REPO" rev-parse HEAD)
} }
##############################################
# Test repo syncing
##############################################
function e2e::repo_sync() {
# Prepare first repo
echo "$FUNCNAME 1" > "$REPO"/file
git -C "$REPO" commit -qam "$FUNCNAME 1"
# First sync
GIT_SYNC \
--repo="file://$REPO" \
--branch="$MAIN_BRANCH" \
--root="$ROOT" \
--dest="link" \
--one-time \
>> "$1" 2>&1
assert_link_exists "$ROOT"/link
assert_file_exists "$ROOT"/link/file
assert_file_eq "$ROOT"/link/file "$FUNCNAME 1"
# Prepare other repo
OTHER_REPO="${REPO}2"
cp -r "$REPO" "$OTHER_REPO"
echo "$FUNCNAME 2" > "$OTHER_REPO"/file
git -C "$OTHER_REPO" commit -qam "$FUNCNAME 2"
# Now sync the other repo
GIT_SYNC \
--repo="file://$OTHER_REPO" \
--branch="$MAIN_BRANCH" \
--root="$ROOT" \
--dest="link" \
--one-time \
>> "$1" 2>&1
assert_link_exists "$ROOT"/link
assert_file_exists "$ROOT"/link/file
assert_file_eq "$ROOT"/link/file "$FUNCNAME 2"
}
############################################## ##############################################
# Test branch syncing # Test branch syncing
############################################## ##############################################