diff options
author | Jannis M. Hoffmann <jannis.hoffmann@rwth-aachen.de> | 2022-04-25 17:13:23 +0200 |
---|---|---|
committer | Jannis M. Hoffmann <jannis.hoffmann@rwth-aachen.de> | 2022-04-25 17:13:23 +0200 |
commit | eae7431ea9ee9d87634b3938b5cf8b64ebdbfb5a (patch) | |
tree | 1d323e5106f5b1eb16a045592ab1bd9d22b6b0e3 /t/Extract.t | |
parent | a97f1a5eb6649e93bfd6584ed590e37c1290755f (diff) |
corrections for last commit
- fixed tests
- added links to languages in about
- raised log level of actions in I18N2
- improved actions script
- corrected dependencies in Makefile.PL
- updated changes
Diffstat (limited to 't/Extract.t')
-rw-r--r-- | t/Extract.t | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/t/Extract.t b/t/Extract.t index 5b719da..7b1ddbf 100644 --- a/t/Extract.t +++ b/t/Extract.t @@ -5,11 +5,12 @@ use utf8; use Test::More; use JSON::PP 'decode_json'; +use List::Util 'min'; no warnings 'experimental::smartmatch'; my $EXTRACT = { - perl_mail_box => 'perl lib/JWebmail/Model/Driver/QMailAuthuser/Extract.pm ', + perl_mail_box => 'perl script/qmauth.pl ', rust_maildir => 'extract/target/debug/jwebmail-extract', }->{perl_mail_box}; my $MAILDIR = 't/'; @@ -18,6 +19,14 @@ my $MAIL_USER = 'maildir'; my $PROG = "$EXTRACT $MAILDIR $SYS_USER $MAIL_USER"; +my $MAIL_COUNT = do { + opendir(my $dh, "$MAILDIR/$MAIL_USER/cur"); + my @all = grep { /^[^.]/ } readdir($dh); + closedir($dh); + local $" = ' '; + note "@all"; + @all +}; subtest start => sub { my @res = `$PROG invalid`; @@ -46,21 +55,22 @@ subtest count => sub { is @res, 1; my $result = decode_json $res[0]; - is($result->{count}, 2); + is($result->{count}, $MAIL_COUNT); #is($result->{new}, 0); }; subtest list => sub { - my @res = `$PROG list 0 10 date ''`; + my $s = "$PROG list 0 4 date ''"; + my @res = `$s`; is($? >> 8, 0); is @res, 1; my $result = decode_json $res[0]; - is(@$result, 2); + is(@$result, min($MAIL_COUNT, 5)); ok($result->[0]{mid}); - ok($result->[0]{from}); - ok($result->[0]{to}); + ok($result->[0]{head}{from}) or diag $s; + ok($result->[0]{head}{to}); }; subtest read => sub { @@ -71,13 +81,14 @@ subtest read => sub { my $pre_result = decode_json $pre_res[0]; ok(my $mid = $pre_result->[0]{mid}); - my @res = `$PROG read-mail '$mid'`; + my $s = "$PROG read-mail '$mid'"; + my @res = `$s`; - is($? >> 8, 0); + is($? >> 8, 0) or (diag $s, return); is @res, 1; my $result = decode_json $res[0]; - is_deeply($result->{from}, [{address => 'shipment-tracking@amazon.de', name => 'Amazon.de'}]); + is_deeply($result->{head}{from}, [{address => 'shipment-tracking@amazon.de', name => 'Amazon.de'}]); ok($result->{date_received}); ok(index($result->{date_received}, '2019-02-22T10:06:54') != -1); like($result->{date_received}, qr'2019-02-22T10:06:54'); |