From 297df5d231840f6369a2bfe3a3683b0b58f2dcd0 Mon Sep 17 00:00:00 2001 From: Tim Byrne Date: Sat, 25 Mar 2017 11:32:06 -0500 Subject: [PATCH] Add tests for classes with a range of names (#51) --- test/108_accept_alt.bats | 72 ++++++++++++++++++++++++++++++++++++++++ test/common.bash | 12 +++++++ 2 files changed, 84 insertions(+) diff --git a/test/108_accept_alt.bats b/test/108_accept_alt.bats index 72d1cdb..6a2b299 100644 --- a/test/108_accept_alt.bats +++ b/test/108_accept_alt.bats @@ -72,6 +72,22 @@ function test_alt() { link_name="alt-override-user" link_match="$link_name##$T_SYS.$T_HOST.custom_user" ;; + class_aaa) + link_name="alt-system" + link_match="$link_name##aaa" + ;; + class_zzz) + link_name="alt-system" + link_match="$link_name##zzz" + ;; + class_AAA) + link_name="alt-system" + link_match="$link_name##AAA" + ;; + class_ZZZ) + link_name="alt-system" + link_match="$link_name##ZZZ" + ;; esac dir_link_name="dir one/${link_name}" dir_link_match="dir one/${link_match}" @@ -195,6 +211,62 @@ function test_alt() { test_alt 'none' 'false' '' } +@test "Command 'alt' (select class - aaa)" { + echo " + When the command 'alt' is provided + and file matches only ##CLASS - aaa + Report the linking + Verify correct file is linked + Exit with 0 + " + + GIT_DIR="$T_DIR_REPO" git config local.class aaa + + test_alt 'class_aaa' 'false' '' +} + +@test "Command 'alt' (select class - zzz)" { + echo " + When the command 'alt' is provided + and file matches only ##CLASS - zzz + Report the linking + Verify correct file is linked + Exit with 0 + " + + GIT_DIR="$T_DIR_REPO" git config local.class zzz + + test_alt 'class_zzz' 'false' '' +} + +@test "Command 'alt' (select class - AAA)" { + echo " + When the command 'alt' is provided + and file matches only ##CLASS - AAA + Report the linking + Verify correct file is linked + Exit with 0 + " + + GIT_DIR="$T_DIR_REPO" git config local.class AAA + + test_alt 'class_AAA' 'false' '' +} + +@test "Command 'alt' (select class - ZZZ)" { + echo " + When the command 'alt' is provided + and file matches only ##CLASS - ZZZ + Report the linking + Verify correct file is linked + Exit with 0 + " + + GIT_DIR="$T_DIR_REPO" git config local.class ZZZ + + test_alt 'class_ZZZ' 'false' '' +} + @test "Command 'auto-alt' (enabled)" { echo " When a command possibly changes the repo diff --git a/test/common.bash b/test/common.bash index 47c9282..03bc7c2 100644 --- a/test/common.bash +++ b/test/common.bash @@ -97,6 +97,10 @@ function create_worktree() { "alt-system##S.H" \ "alt-system##S.H.U" \ "alt-system##$T_SYS" \ + "alt-system##AAA" \ + "alt-system##ZZZ" \ + "alt-system##aaa" \ + "alt-system##zzz" \ "alt-host##" \ "alt-host##S" \ "alt-host##S.H" \ @@ -142,6 +146,14 @@ function create_worktree() { "dir one/alt-system##S.H.U/file2" \ "dir one/alt-system##$T_SYS/file1" \ "dir one/alt-system##$T_SYS/file2" \ + "dir one/alt-system##AAA/file1" \ + "dir one/alt-system##AAA/file2" \ + "dir one/alt-system##ZZZ/file1" \ + "dir one/alt-system##ZZZ/file2" \ + "dir one/alt-system##aaa/file1" \ + "dir one/alt-system##aaa/file2" \ + "dir one/alt-system##zzz/file1" \ + "dir one/alt-system##zzz/file2" \ "dir one/alt-host##/file1" \ "dir one/alt-host##/file2" \ "dir one/alt-host##S/file1" \