add unit tests for adjust_dotfiles()

This commit is contained in:
Adam Spiers 2024-03-31 23:51:14 +01:00
parent 2f762e3908
commit 8c09d41054

View file

@ -22,16 +22,35 @@
use strict; use strict;
use warnings; use warnings;
use testutil; use Test::More tests => 11;
use Test::More tests => 10;
use English qw(-no_match_vars); use English qw(-no_match_vars);
use Stow::Util qw(adjust_dotfile);
use testutil; use testutil;
init_test_dirs(); init_test_dirs();
cd("$TEST_DIR/target"); cd("$TEST_DIR/target");
subtest('adjust_dotfile()', sub {
plan tests => 9;
my @TESTS = (
['file'],
['dot-file', '.file'],
['dir1/file'],
['dir1/dir2/file'],
['dir1/dir2/dot-file', 'dir1/dir2/.file'],
['dir1/dot-dir2/file', 'dir1/.dir2/file'],
['dir1/dot-dir2/dot-file', 'dir1/.dir2/.file'],
['dot-dir1/dot-dir2/dot-file', '.dir1/.dir2/.file'],
['dot-dir1/dot-dir2/file', '.dir1/.dir2/file'],
);
for my $test (@TESTS) {
my ($input, $expected) = @$test;
$expected ||= $input;
is(adjust_dotfile($input), $expected);
}
});
my $stow; my $stow;
# #