|
|
|
@ -1,5 +1,6 @@ |
|
|
|
|
load common |
|
|
|
|
load_fixtures |
|
|
|
|
status=;output=; #; populated by bats run() |
|
|
|
|
|
|
|
|
|
setup() { |
|
|
|
|
destroy_tmp |
|
|
|
@ -20,18 +21,18 @@ setup() { |
|
|
|
|
" |
|
|
|
|
|
|
|
|
|
#; run init |
|
|
|
|
run $T_YADM_Y init |
|
|
|
|
run "${T_YADM_Y[@]}" init |
|
|
|
|
|
|
|
|
|
#; validate status and output |
|
|
|
|
[ $status -eq 0 ] |
|
|
|
|
[[ "$output" =~ Initialized ]] |
|
|
|
|
|
|
|
|
|
#; validate repo attributes |
|
|
|
|
test_perms $T_DIR_REPO "drw.--.--." |
|
|
|
|
test_repo_attribute $T_DIR_REPO core.bare false |
|
|
|
|
test_repo_attribute $T_DIR_REPO core.worktree "$HOME" |
|
|
|
|
test_repo_attribute $T_DIR_REPO status.showUntrackedFiles no |
|
|
|
|
test_repo_attribute $T_DIR_REPO yadm.managed true |
|
|
|
|
test_perms "$T_DIR_REPO" "drw.--.--." |
|
|
|
|
test_repo_attribute "$T_DIR_REPO" core.bare false |
|
|
|
|
test_repo_attribute "$T_DIR_REPO" core.worktree "$HOME" |
|
|
|
|
test_repo_attribute "$T_DIR_REPO" status.showUntrackedFiles no |
|
|
|
|
test_repo_attribute "$T_DIR_REPO" yadm.managed true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@test "Command 'init' -w (alternate worktree)" { |
|
|
|
@ -49,18 +50,18 @@ setup() { |
|
|
|
|
" |
|
|
|
|
|
|
|
|
|
#; run init |
|
|
|
|
run $T_YADM_Y init -w "$T_DIR_WORK" |
|
|
|
|
run "${T_YADM_Y[@]}" init -w "$T_DIR_WORK" |
|
|
|
|
|
|
|
|
|
#; validate status and output |
|
|
|
|
[ $status -eq 0 ] |
|
|
|
|
[[ "$output" =~ Initialized ]] |
|
|
|
|
|
|
|
|
|
#; validate repo attributes |
|
|
|
|
test_perms $T_DIR_REPO "drw.--.--." |
|
|
|
|
test_repo_attribute $T_DIR_REPO core.bare false |
|
|
|
|
test_repo_attribute $T_DIR_REPO core.worktree "$T_DIR_WORK" |
|
|
|
|
test_repo_attribute $T_DIR_REPO status.showUntrackedFiles no |
|
|
|
|
test_repo_attribute $T_DIR_REPO yadm.managed true |
|
|
|
|
test_perms "$T_DIR_REPO" "drw.--.--." |
|
|
|
|
test_repo_attribute "$T_DIR_REPO" core.bare false |
|
|
|
|
test_repo_attribute "$T_DIR_REPO" core.worktree "$T_DIR_WORK" |
|
|
|
|
test_repo_attribute "$T_DIR_REPO" status.showUntrackedFiles no |
|
|
|
|
test_repo_attribute "$T_DIR_REPO" yadm.managed true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@test "Command 'init' (existing repo)" { |
|
|
|
@ -72,19 +73,19 @@ setup() { |
|
|
|
|
" |
|
|
|
|
|
|
|
|
|
#; create existing repo content |
|
|
|
|
mkdir -p $T_DIR_REPO |
|
|
|
|
mkdir -p "$T_DIR_REPO" |
|
|
|
|
local testfile="$T_DIR_REPO/testfile" |
|
|
|
|
touch "$testfile" |
|
|
|
|
|
|
|
|
|
#; run init |
|
|
|
|
run $T_YADM_Y init |
|
|
|
|
run "${T_YADM_Y[@]}" init |
|
|
|
|
|
|
|
|
|
#; validate status and output |
|
|
|
|
[ $status -eq 1 ] |
|
|
|
|
[[ "$output" =~ already.exists ]] |
|
|
|
|
|
|
|
|
|
#; verify existing repo is intact |
|
|
|
|
if [ ! -e $testfile ]; then |
|
|
|
|
if [ ! -e "$testfile" ]; then |
|
|
|
|
echo "ERROR: existing repo has been changed" |
|
|
|
|
return 1 |
|
|
|
|
fi |
|
|
|
@ -108,29 +109,29 @@ setup() { |
|
|
|
|
" |
|
|
|
|
|
|
|
|
|
#; create existing repo content |
|
|
|
|
mkdir -p $T_DIR_REPO |
|
|
|
|
mkdir -p "$T_DIR_REPO" |
|
|
|
|
local testfile="$T_DIR_REPO/testfile" |
|
|
|
|
touch "$testfile" |
|
|
|
|
|
|
|
|
|
#; run init |
|
|
|
|
run $T_YADM_Y init -f |
|
|
|
|
run "${T_YADM_Y[@]}" init -f |
|
|
|
|
|
|
|
|
|
#; validate status and output |
|
|
|
|
[ $status -eq 0 ] |
|
|
|
|
[[ "$output" =~ Initialized ]] |
|
|
|
|
|
|
|
|
|
#; verify existing repo is gone |
|
|
|
|
if [ -e $testfile ]; then |
|
|
|
|
if [ -e "$testfile" ]; then |
|
|
|
|
echo "ERROR: existing repo files remain" |
|
|
|
|
return 1 |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
#; validate repo attributes |
|
|
|
|
test_perms $T_DIR_REPO "drw.--.--." |
|
|
|
|
test_repo_attribute $T_DIR_REPO core.bare false |
|
|
|
|
test_repo_attribute $T_DIR_REPO core.worktree "$HOME" |
|
|
|
|
test_repo_attribute $T_DIR_REPO status.showUntrackedFiles no |
|
|
|
|
test_repo_attribute $T_DIR_REPO yadm.managed true |
|
|
|
|
test_perms "$T_DIR_REPO" "drw.--.--." |
|
|
|
|
test_repo_attribute "$T_DIR_REPO" core.bare false |
|
|
|
|
test_repo_attribute "$T_DIR_REPO" core.worktree "$HOME" |
|
|
|
|
test_repo_attribute "$T_DIR_REPO" status.showUntrackedFiles no |
|
|
|
|
test_repo_attribute "$T_DIR_REPO" yadm.managed true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@test "Command 'init' -f -w (force overwrite repo with alternate worktree)" { |
|
|
|
@ -151,27 +152,27 @@ setup() { |
|
|
|
|
" |
|
|
|
|
|
|
|
|
|
#; create existing repo content |
|
|
|
|
mkdir -p $T_DIR_REPO |
|
|
|
|
mkdir -p "$T_DIR_REPO" |
|
|
|
|
local testfile="$T_DIR_REPO/testfile" |
|
|
|
|
touch "$testfile" |
|
|
|
|
|
|
|
|
|
#; run init |
|
|
|
|
run $T_YADM_Y init -f -w "$T_DIR_WORK" |
|
|
|
|
run "${T_YADM_Y[@]}" init -f -w "$T_DIR_WORK" |
|
|
|
|
|
|
|
|
|
#; validate status and output |
|
|
|
|
[ $status -eq 0 ] |
|
|
|
|
[[ "$output" =~ Initialized ]] |
|
|
|
|
|
|
|
|
|
#; verify existing repo is gone |
|
|
|
|
if [ -e $testfile ]; then |
|
|
|
|
if [ -e "$testfile" ]; then |
|
|
|
|
echo "ERROR: existing repo files remain" |
|
|
|
|
return 1 |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
#; validate repo attributes |
|
|
|
|
test_perms $T_DIR_REPO "drw.--.--." |
|
|
|
|
test_repo_attribute $T_DIR_REPO core.bare false |
|
|
|
|
test_repo_attribute $T_DIR_REPO core.worktree "$T_DIR_WORK" |
|
|
|
|
test_repo_attribute $T_DIR_REPO status.showUntrackedFiles no |
|
|
|
|
test_repo_attribute $T_DIR_REPO yadm.managed true |
|
|
|
|
test_perms "$T_DIR_REPO" "drw.--.--." |
|
|
|
|
test_repo_attribute "$T_DIR_REPO" core.bare false |
|
|
|
|
test_repo_attribute "$T_DIR_REPO" core.worktree "$T_DIR_WORK" |
|
|
|
|
test_repo_attribute "$T_DIR_REPO" status.showUntrackedFiles no |
|
|
|
|
test_repo_attribute "$T_DIR_REPO" yadm.managed true |
|
|
|
|
} |
|
|
|
|