mirror of
1
0
Fork 0

Add tests for globbing

This commit is contained in:
Anish Athalye 2018-04-06 22:09:57 +05:30
parent 7d069b4ac8
commit 8d08e4b1ad
3 changed files with 123 additions and 0 deletions

View File

@ -0,0 +1,45 @@
test_description='link glob ambiguous'
. '../test-lib.bash'
test_expect_success 'setup' '
mkdir ${DOTFILES}/bin
'
test_expect_failure 'run 1' '
run_dotbot <<EOF
- link:
~/bin/:
path: bin
glob: true
EOF
'
test_expect_failure 'test 1' '
test -d ~/bin
'
test_expect_failure 'run 2' '
run_dotbot <<EOF
- link:
~/bin/:
path: bin/
glob: true
EOF
'
test_expect_failure 'test 2' '
test -d ~/bin
'
test_expect_success 'run 3' '
run_dotbot <<EOF
- link:
~/bin:
path: bin
glob: true
EOF
'
test_expect_success 'test 3' '
test -d ~/bin
'

View File

@ -0,0 +1,31 @@
test_description='link glob'
. '../test-lib.bash'
test_expect_success 'setup' '
mkdir ${DOTFILES}/config &&
mkdir ${DOTFILES}/config/foo &&
mkdir ${DOTFILES}/config/bar &&
echo "apple" > ${DOTFILES}/config/foo/a &&
echo "banana" > ${DOTFILES}/config/bar/b &&
echo "cherry" > ${DOTFILES}/config/bar/c
'
test_expect_success 'run' '
run_dotbot -v <<EOF
- defaults:
link:
glob: true
create: true
- link:
~/.config/: config/*/*
EOF
'
test_expect_success 'test' '
! readlink ~/.config/ &&
! readlink ~/.config/foo &&
readlink ~/.config/foo/a &&
grep "apple" ~/.config/foo/a &&
grep "banana" ~/.config/bar/b &&
grep "cherry" ~/.config/bar/c
'

47
test/tests/link-glob.bash Normal file
View File

@ -0,0 +1,47 @@
test_description='link glob'
. '../test-lib.bash'
test_expect_success 'setup 1' '
mkdir ${DOTFILES}/bin &&
echo "apple" > ${DOTFILES}/bin/a &&
echo "banana" > ${DOTFILES}/bin/b &&
echo "cherry" > ${DOTFILES}/bin/c
'
test_expect_success 'run 1' '
run_dotbot -v <<EOF
- defaults:
link:
glob: true
create: true
- link:
~/bin: bin/*
EOF
'
test_expect_success 'test 1' '
grep "apple" ~/bin/a &&
grep "banana" ~/bin/b &&
grep "cherry" ~/bin/c
'
test_expect_success 'setup 2' '
rm -rf ~/bin
'
test_expect_success 'run 2' '
run_dotbot -v <<EOF
- defaults:
link:
glob: true
create: true
- link:
~/bin/: bin/*
EOF
'
test_expect_success 'test 2' '
grep "apple" ~/bin/a &&
grep "banana" ~/bin/b &&
grep "cherry" ~/bin/c
'