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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
#!/usr/bin/perl
use v5.14;
use utf8;
use Test::More;
use Test::Fatal;
use Test::Deep qw(:v1);
use Path::Tiny;
use Log::Any::Test;
use Log::Any qw($log);
use strictures 2;
no warnings "experimental::signatures";
use_ok('Boxer::Task::Classify');
subtest 'from examples' => sub {
my $classifier = new_ok(
'Boxer::Task::Classify' => [ datadir => path('examples'), ] );
$log->empty_ok("no more logs");
my $world = $classifier->run;
isa_ok $world, 'Boxer::World',
'classified world is a Boxer::World';
$log->category_contains_ok(
'Boxer::Task::Classify',
qr/^Resolving nodedir /, 'datadir logged'
);
$log->category_contains_ok(
'Boxer::Task::Classify',
qr/^Resolving classdir /, 'classdir logged'
);
$log->category_contains_ok(
'Boxer::Task::Classify',
qr/^Classifying /, 'classification logged'
);
$log->empty_ok("no more logs");
};
subtest 'from empty dirs' => sub {
my $dir = Path::Tiny->tempdir;
note("Temporary directory is $dir");
my $classifier = new_ok( 'Boxer::Task::Classify' => [ datadir => $dir ] );
$log->empty_ok("no more logs");
like exception {
$classifier->run;
}, qr/Must be an existing directory /, 'Died as expected';
$log->category_contains_ok(
'Boxer::Task::Classify',
qr/^Resolving classdir from /, 'classdir logged'
);
$log->empty_ok("no more logs");
};
subtest 'from non-existing dirs' => sub {
my $dir = Path::Tiny->tempdir;
note("Temporary directory is $dir");
like exception {
Boxer::Task::Classify->new( datadir => $dir->child('foo') );
}, qr/Directory '\S+' does not exist/, 'Died as expected';
$log->empty_ok("no more logs");
};
done_testing();
|