summaryrefslogtreecommitdiff
path: root/test/tests/link-if.bash
blob: 1ea77094605a6f761269dc0b534bd705b70a9711 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
test_description='link if'
. '../test-lib.bash'

test_expect_success 'setup' '
mkdir ~/d
echo "apple" > ${DOTFILES}/f
'

test_expect_success 'run' '
run_dotbot <<EOF
- link:
    ~/.f:
        path: f
        if: "true"
    ~/.g:
        path: f
        if: "false"
    ~/.h:
        path: f
        if: "[[ -d ~/d ]]"
    ~/.i:
        path: f
        if: "badcommand"
EOF
'

test_expect_success 'test' '
grep "apple" ~/.f &&
! test -f ~/.g &&
grep "apple" ~/.h &&
! test -f ~/.i
'

test_expect_success 'run 2' '
run_dotbot <<EOF
- defaults:
    link:
      if: "false"
- link:
    ~/.j:
        path: f
        if: "true"
    ~/.k:
        path: f
EOF
'

test_expect_success 'test 2' '
grep "apple" ~/.j &&
! test -f ~/.k
'