Skip to content

Commit

Permalink
t/0[25]*.t: improve test coverage
Browse files Browse the repository at this point in the history
Prove some calling restrictions for config_dirs and providers
and test another misusage of _plug_dir_source.

Signed-off-by: Jens Rehsack <sno@netbsd.org>
  • Loading branch information
rehsack committed Apr 27, 2018
1 parent 3100376 commit b4a9415
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions t/02-plugg.t
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ ok(File::ConfigDir::_plug_dir_source($pure_src, "0E0"), "registered pure plugin"

ok(!File::ConfigDir::_plug_dir_source(), "registered nothing");
ok(!File::ConfigDir::_plug_dir_source(undef), "registered undef");
ok(!File::ConfigDir::_plug_dir_source(42), "registered 42");

my @dirs = config_dirs();
note("config_dirs: " . join(",", @dirs));
Expand Down
31 changes: 31 additions & 0 deletions t/05-errors.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!perl

use strict;
use warnings;

use Test::More;

use File::ConfigDir ();

foreach my $fn (
qw(config_dirs system_cfg_dir desktop_cfg_dir),
qw(core_cfg_dir site_cfg_dir vendor_cfg_dir),
qw(local_cfg_dir here_cfg_dir vendorapp_cfg_dir),
qw(xdg_config_home user_cfg_dir locallib_cfg_dir),
)
{
my $faddr = File::ConfigDir->can($fn);
eval { $faddr->(qw(foo bar)); };
my $exception = $@;
like($exception, qr/$fn\(;\$\), not $fn\(\$,\$\)/, "$fn throws exception on misuse");
}

foreach my $fn (qw(singleapp_cfg_dir))
{
my $faddr = File::ConfigDir->can($fn);
eval { $faddr->(qw(foo bar)); };
my $exception = $@;
like($exception, qr/$fn\(\), not $fn\(\$,\$\)/, "$fn throws exception on misuse");
}

done_testing;

0 comments on commit b4a9415

Please sign in to comment.