summaryrefslogtreecommitdiff
path: root/t/Extract.t
diff options
context:
space:
mode:
Diffstat (limited to 't/Extract.t')
-rw-r--r--t/Extract.t49
1 files changed, 26 insertions, 23 deletions
diff --git a/t/Extract.t b/t/Extract.t
index 7b1ddbf..3a18395 100644
--- a/t/Extract.t
+++ b/t/Extract.t
@@ -6,13 +6,13 @@ use Test::More;
use JSON::PP 'decode_json';
use List::Util 'min';
-no warnings 'experimental::smartmatch';
my $EXTRACT = {
- perl_mail_box => 'perl script/qmauth.pl ',
- rust_maildir => 'extract/target/debug/jwebmail-extract',
-}->{perl_mail_box};
+ perl_mail_box => 'perl script/qmauth.pl',
+ python_mailbox => 'python script/qmauth.py',
+ rust_maildir => 'extract/target/debug/jwebmail-extract',
+}->{python_mailbox};
my $MAILDIR = 't/';
my $SYS_USER = $ENV{USER};
my $MAIL_USER = 'maildir';
@@ -29,13 +29,15 @@ my $MAIL_COUNT = do {
};
subtest start => sub {
- my @res = `$PROG invalid`;
+ my @res = `$PROG invalid 2>/dev/null`;
- is($? >> 8, 3);
- is @res, 1;
- my $result = decode_json $res[0];
+ isnt $? >> 8, 0;
- ok($result->{error})
+ if ($? >> 8 == 3) {
+ is scalar(@res), 1;
+ my $result = decode_json @res;
+ ok exists $result->{error};
+ }
};
subtest folders => sub {
@@ -55,43 +57,44 @@ subtest count => sub {
is @res, 1;
my $result = decode_json $res[0];
- is($result->{count}, $MAIL_COUNT);
- #is($result->{new}, 0);
+ is($result->{total_mails}, $MAIL_COUNT);
};
subtest list => sub {
- my $s = "$PROG list 0 4 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, min($MAIL_COUNT, 5));
- ok($result->[0]{mid});
+ is(@$result, min($MAIL_COUNT, 4));
+ ok($result->[0]{message_handle});
ok($result->[0]{head}{from}) or diag $s;
ok($result->[0]{head}{to});
};
subtest read => sub {
- my @pre_res = `$PROG list 0 10 date ''`;
+ my $folder = '';
+ my @pre_res = `$PROG list '$folder' 0 10 ''`;
is($? >> 8, 0);
is @pre_res, 1;
my $pre_result = decode_json $pre_res[0];
- ok(my $mid = $pre_result->[0]{mid});
+ ok(my $mid = $pre_result->[0]{message_handle});
- my $s = "$PROG read-mail '$mid'";
- my @res = `$s`;
+ my @res = `$PROG read '$folder' '$mid'`;
- is($? >> 8, 0) or (diag $s, return);
+ is($? >> 8, 0, "read exit code") or (diag @res, return);
is @res, 1;
my $result = decode_json $res[0];
- 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');
+ is_deeply(
+ $result->{head}{from},
+ [{address => 'xy@example.com', display_name => 'Moderator-Address'}],
+ );
+ ok(exists $result->{head}{date});
+ is($result->{head}{date}, '1994-03-22T13:34:51+00:00');
};
done_testing;