Acceptance tests for overriding OS/Host/User (#21)
This commit is contained in:
parent
eaa252f721
commit
1534420106
2 changed files with 83 additions and 0 deletions
|
@ -59,6 +59,18 @@ function test_alt() {
|
||||||
link_name="encrypted-user"
|
link_name="encrypted-user"
|
||||||
link_match="$link_name##$T_SYS.$T_HOST.$T_USER"
|
link_match="$link_name##$T_SYS.$T_HOST.$T_USER"
|
||||||
;;
|
;;
|
||||||
|
override_system)
|
||||||
|
link_name="alt-override-system"
|
||||||
|
link_match="$link_name##custom_system"
|
||||||
|
;;
|
||||||
|
override_host)
|
||||||
|
link_name="alt-override-host"
|
||||||
|
link_match="$link_name##$T_SYS.custom_host"
|
||||||
|
;;
|
||||||
|
override_user)
|
||||||
|
link_name="alt-override-user"
|
||||||
|
link_match="$link_name##$T_SYS.$T_HOST.custom_user"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
dir_link_name="dir one/${link_name}"
|
dir_link_name="dir one/${link_name}"
|
||||||
dir_link_match="dir one/${link_match}"
|
dir_link_match="dir one/${link_match}"
|
||||||
|
@ -112,6 +124,8 @@ function test_alt() {
|
||||||
link_content=$(cat "$T_DIR_WORK/$link_name")
|
link_content=$(cat "$T_DIR_WORK/$link_name")
|
||||||
dir_link_content=$(cat "$T_DIR_WORK/$dir_link_name/file1")
|
dir_link_content=$(cat "$T_DIR_WORK/$dir_link_name/file1")
|
||||||
if [ "$link_content" != "$link_match" ] || [ "$dir_link_content" != "$dir_link_match/file1" ]; then
|
if [ "$link_content" != "$link_match" ] || [ "$dir_link_content" != "$dir_link_match/file1" ]; then
|
||||||
|
echo "link_content: $link_content"
|
||||||
|
echo "dir_link_content: $dir_link_content"
|
||||||
echo "ERROR: Link content is not correct"
|
echo "ERROR: Link content is not correct"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
@ -270,3 +284,45 @@ function test_alt() {
|
||||||
|
|
||||||
test_alt 'encrypted_none' 'false' ''
|
test_alt 'encrypted_none' 'false' ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "Command 'alt' (override-system)" {
|
||||||
|
echo "
|
||||||
|
When the command 'alt' is provided
|
||||||
|
and file matches only ##SYSTEM
|
||||||
|
after setting alt.os
|
||||||
|
Report the linking
|
||||||
|
Verify correct file is linked
|
||||||
|
Exit with 0
|
||||||
|
"
|
||||||
|
|
||||||
|
git config --file="$T_YADM_CONFIG" alt.os custom_system
|
||||||
|
test_alt 'override_system' 'false' ''
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "Command 'alt' (override-host)" {
|
||||||
|
echo "
|
||||||
|
When the command 'alt' is provided
|
||||||
|
and file matches only ##SYSTEM.HOST
|
||||||
|
after setting alt.host
|
||||||
|
Report the linking
|
||||||
|
Verify correct file is linked
|
||||||
|
Exit with 0
|
||||||
|
"
|
||||||
|
|
||||||
|
git config --file="$T_YADM_CONFIG" alt.host custom_host
|
||||||
|
test_alt 'override_host' 'false' ''
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "Command 'alt' (override-user)" {
|
||||||
|
echo "
|
||||||
|
When the command 'alt' is provided
|
||||||
|
and file matches only ##SYSTEM.HOST.USER
|
||||||
|
after setting alt.user
|
||||||
|
Report the linking
|
||||||
|
Verify correct file is linked
|
||||||
|
Exit with 0
|
||||||
|
"
|
||||||
|
|
||||||
|
git config --file="$T_YADM_CONFIG" alt.user custom_user
|
||||||
|
test_alt 'override_user' 'false' ''
|
||||||
|
}
|
||||||
|
|
|
@ -106,6 +106,15 @@ function create_worktree() {
|
||||||
"alt-user##S.H.U" \
|
"alt-user##S.H.U" \
|
||||||
"alt-user##$T_SYS.$T_HOST.$T_USER" \
|
"alt-user##$T_SYS.$T_HOST.$T_USER" \
|
||||||
"alt-user##${T_SYS}_${T_HOST}_${T_USER}" \
|
"alt-user##${T_SYS}_${T_HOST}_${T_USER}" \
|
||||||
|
"alt-override-system##" \
|
||||||
|
"alt-override-system##$T_SYS" \
|
||||||
|
"alt-override-system##custom_system" \
|
||||||
|
"alt-override-host##" \
|
||||||
|
"alt-override-host##$T_SYS.$T_HOST" \
|
||||||
|
"alt-override-host##$T_SYS.custom_host" \
|
||||||
|
"alt-override-user##" \
|
||||||
|
"alt-override-user##S.H.U" \
|
||||||
|
"alt-override-user##$T_SYS.$T_HOST.custom_user" \
|
||||||
"dir one/alt-none##S/file1" \
|
"dir one/alt-none##S/file1" \
|
||||||
"dir one/alt-none##S/file2" \
|
"dir one/alt-none##S/file2" \
|
||||||
"dir one/alt-none##S.H/file1" \
|
"dir one/alt-none##S.H/file1" \
|
||||||
|
@ -154,6 +163,24 @@ function create_worktree() {
|
||||||
"dir one/alt-user##$T_SYS.$T_HOST.$T_USER/file2" \
|
"dir one/alt-user##$T_SYS.$T_HOST.$T_USER/file2" \
|
||||||
"dir one/alt-user##${T_SYS}_${T_HOST}_${T_USER}/file1" \
|
"dir one/alt-user##${T_SYS}_${T_HOST}_${T_USER}/file1" \
|
||||||
"dir one/alt-user##${T_SYS}_${T_HOST}_${T_USER}/file2" \
|
"dir one/alt-user##${T_SYS}_${T_HOST}_${T_USER}/file2" \
|
||||||
|
"dir one/alt-override-system##/file1" \
|
||||||
|
"dir one/alt-override-system##/file2" \
|
||||||
|
"dir one/alt-override-system##$T_SYS/file1" \
|
||||||
|
"dir one/alt-override-system##$T_SYS/file2" \
|
||||||
|
"dir one/alt-override-system##custom_system/file1" \
|
||||||
|
"dir one/alt-override-system##custom_system/file2" \
|
||||||
|
"dir one/alt-override-host##/file1" \
|
||||||
|
"dir one/alt-override-host##/file2" \
|
||||||
|
"dir one/alt-override-host##$T_SYS.$T_HOST/file1" \
|
||||||
|
"dir one/alt-override-host##$T_SYS.$T_HOST/file2" \
|
||||||
|
"dir one/alt-override-host##$T_SYS.custom_host/file1" \
|
||||||
|
"dir one/alt-override-host##$T_SYS.custom_host/file2" \
|
||||||
|
"dir one/alt-override-user##/file1" \
|
||||||
|
"dir one/alt-override-user##/file2" \
|
||||||
|
"dir one/alt-override-user##S.H.U/file1" \
|
||||||
|
"dir one/alt-override-user##S.H.U/file2" \
|
||||||
|
"dir one/alt-override-user##$T_SYS.$T_HOST.custom_user/file1" \
|
||||||
|
"dir one/alt-override-user##$T_SYS.$T_HOST.custom_user/file2" \
|
||||||
"dir2/file2" \
|
"dir2/file2" \
|
||||||
.bash_profile \
|
.bash_profile \
|
||||||
.gnupg/gpg.conf \
|
.gnupg/gpg.conf \
|
||||||
|
|
Loading…
Reference in a new issue