From 056d648d53949f173f91edf70a0eb8145da8b2c1 Mon Sep 17 00:00:00 2001 From: ATuinDev <1757663+AitorATuin@users.noreply.github.com> Date: Mon, 25 May 2020 22:23:23 +0200 Subject: [PATCH] Add more tests for testing directories in dotfiles.t --- t/dotfiles.t | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) diff --git a/t/dotfiles.t b/t/dotfiles.t index a4a45c8..9e70ad4 100755 --- a/t/dotfiles.t +++ b/t/dotfiles.t @@ -24,7 +24,7 @@ use warnings; use testutil; -use Test::More tests => 6; +use Test::More tests => 10; use English qw(-no_match_vars); use testutil; @@ -86,6 +86,64 @@ is( => 'processed dotfile folder' ); +# +# process folder marked with 'dot' prefix +# when directory exists is target +# + +$stow = new_Stow(dir => '../stow', dotfiles => 1); + +make_path('../stow/dotfiles/dot-emacs.d'); +make_file('../stow/dotfiles/dot-emacs.d/init.el'); +make_path('.emacs.d'); + +$stow->plan_stow('dotfiles'); +$stow->process_tasks(); +is( + readlink('.emacs.d/init.el'), + '../../stow/dotfiles/dot-emacs.d/init.el', + => 'processed dotfile folder when folder exists (1 level)' +); + +# +# process folder marked with 'dot' prefix +# when directory exists is target (2 levels) +# + +$stow = new_Stow(dir => '../stow', dotfiles => 1); + +make_path('../stow/dotfiles/dot-emacs.d/dot-emacs.d'); +make_file('../stow/dotfiles/dot-emacs.d/dot-emacs.d/init.el'); +make_path('.emacs.d'); + +$stow->plan_stow('dotfiles'); +$stow->process_tasks(); +is( + readlink('.emacs.d/.emacs.d'), + '../../stow/dotfiles/dot-emacs.d/dot-emacs.d', + => 'processed dotfile folder exists (2 levels)' +); + +# +# process folder marked with 'dot' prefix +# when directory exists is target +# + +$stow = new_Stow(dir => '../stow', dotfiles => 1); + +make_path('../stow/dotfiles/dot-one/dot-two'); +make_file('../stow/dotfiles/dot-one/dot-two/three'); +make_path('.one/.two'); + +$stow->plan_stow('dotfiles'); +$stow->process_tasks(); +is( + readlink('./.one/.two/three'), + '../../../stow/dotfiles/dot-one/dot-two/three', + => 'processed dotfile 2 folder exists (2 levels)' +); + + # # corner case: paths that have a part in them that's just "$DOT_PREFIX" or # "$DOT_PREFIX." should not have that part expanded. @@ -129,3 +187,25 @@ ok( -f '../stow/dotfiles/dot-bar' && ! -e '.bar' => 'unstow a simple dotfile' ); + +# +# unstow process folder marked with 'dot' prefix +# when directory exists is target +# + +$stow = new_Stow(dir => '../stow', dotfiles => 1); + +make_path('../stow/dotfiles/dot-emacs.d'); +make_file('../stow/dotfiles/dot-emacs.d/init.el'); +make_path('.emacs.d'); +make_link('.emacs.d/init.el', '../../stow/dotfiles/dot-emacs.d/init.el'); + +$stow->plan_unstow('dotfiles'); +$stow->process_tasks(); +ok( + $stow->get_conflict_count == 0 && + -f '../stow/dotfiles/dot-emacs.d/init.el' && + ! -e '.emacs.d/init.el' && + -d '.emacs.d/' + => 'unstow dotfile folder when folder already exists' +);