From 1534420106f32113ca8e31124ded8fadb7e19704 Mon Sep 17 00:00:00 2001 From: Tim Byrne Date: Wed, 18 Jan 2017 19:51:13 -0600 Subject: [PATCH] Acceptance tests for overriding OS/Host/User (#21) --- test/108_accept_alt.bats | 56 ++++++++++++++++++++++++++++++++++++++++ test/common.bash | 27 +++++++++++++++++++ 2 files changed, 83 insertions(+) diff --git a/test/108_accept_alt.bats b/test/108_accept_alt.bats index e373ada..b83f425 100644 --- a/test/108_accept_alt.bats +++ b/test/108_accept_alt.bats @@ -59,6 +59,18 @@ function test_alt() { link_name="encrypted-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 dir_link_name="dir one/${link_name}" dir_link_match="dir one/${link_match}" @@ -112,6 +124,8 @@ function test_alt() { link_content=$(cat "$T_DIR_WORK/$link_name") dir_link_content=$(cat "$T_DIR_WORK/$dir_link_name/file1") 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" return 1 fi @@ -270,3 +284,45 @@ function test_alt() { 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' '' +} diff --git a/test/common.bash b/test/common.bash index 65a3610..ab4aec1 100644 --- a/test/common.bash +++ b/test/common.bash @@ -106,6 +106,15 @@ function create_worktree() { "alt-user##S.H.U" \ "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/file2" \ "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}/file1" \ "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" \ .bash_profile \ .gnupg/gpg.conf \