Skip to content

Commit

Permalink
Test code for commit 806e465 #399
Browse files Browse the repository at this point in the history
  • Loading branch information
azumakuniyuki committed Jun 9, 2020
1 parent a277a82 commit f281fd4
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion t/001-sisimai.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use Test::More;
use lib qw(./lib ./blib/lib);
use IO::File;
use Sisimai;
use Time::Piece;
use JSON;
require './t/999-values.pl';

Expand Down Expand Up @@ -96,6 +97,14 @@ MAKE_TEST: {
}

my $havecaught = undef;
my $emailhooks = sub {
my $argvs = shift;
my $timep = localtime(Time::Piece->new);

for my $p ( @{ $argvs->{'sisi'} } ) {
$p->{'parsedat'} = sprintf("%s %s", $timep->ymd('-'), $timep->hms);
}
};
my $callbackto = sub {
my $argvs = shift;
my $catch = {
Expand All @@ -110,7 +119,7 @@ MAKE_TEST: {
$catch->{'return-path'} = $1 if $argvs->{'message'} =~ m/^Return-Path:\s*(.+)$/m;
return $catch;
};
$havecaught = $PackageName->make($SampleEmail->{ $e }, 'hook' => $callbackto);
$havecaught = $PackageName->make($SampleEmail->{ $e }, 'hook' => $callbackto, 'c___' => $emailhooks);

for my $ee ( @$havecaught ) {
isa_ok $ee, 'Sisimai::Data';
Expand All @@ -135,6 +144,11 @@ MAKE_TEST: {
if( length $ee->catch->{'x-virus-scanned'} ) {
like $ee->catch->{'x-virus-scanned'}, qr/(?:amavis|clam)/i;
}

ok defined $ee->{'parsedat'};
if( length $ee->{'parsedat'} ) {
like $ee->{'parsedat'}, qr/\A\d{4}[-]\d{2}[-]\d{2}/;
}
}

my $isntmethod = $PackageName->make($SampleEmail->{ $e }, 'hook' => {});
Expand Down

0 comments on commit f281fd4

Please sign in to comment.