diff options
author | Jannis M. Hoffmann <jannis.hoffmann@rwth-aachen.de> | 2020-11-12 23:14:45 +0100 |
---|---|---|
committer | Jannis M. Hoffmann <jannis.hoffmann@rwth-aachen.de> | 2020-11-12 23:14:45 +0100 |
commit | 487629cca62c29719e44df2e68cf14d8b0cc2f3e (patch) | |
tree | 28c3363e7664ad3be26a6cb2a648843f0a62f237 /t/Extract.t | |
parent | 13e688099ec80cbbd6e806437922df4270498c12 (diff) |
+ moved changes out of Readme into its own file
+ corrected dependecies
+ switched to different I18N handling
+ added test
+ updated name for status file to is_multipart
Diffstat (limited to 't/Extract.t')
-rw-r--r-- | t/Extract.t | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/t/Extract.t b/t/Extract.t new file mode 100644 index 0000000..1d20d0f --- /dev/null +++ b/t/Extract.t @@ -0,0 +1,84 @@ +use v5.22; +use warnings; +use utf8; + +use Test::More; + +use JSON::PP 'decode_json'; +no warnings 'experimental::smartmatch'; + + +my $EXTRACT = { + perl_mail_box => 'perl lib/JWebmail/Model/Driver/QMailAuthuser/Extract.pm ', + rust_maildir => 'extract/target/debug/jwebmail-extract', +}->{perl_mail_box}; +my $MAILDIR = 't/'; +my $SYS_USER = $ENV{USER}; +my $MAIL_USER = 'maildir'; + +my $PROG = "$EXTRACT $MAILDIR $SYS_USER $MAIL_USER"; + + +subtest start => sub { + my @res = `$PROG invalid`; + + is($? >> 8, 3); + is @res, 1; + my $result = decode_json $res[0]; + + ok($result->{error}) +}; + +subtest folders => sub { + my @res = `$PROG folders`; + + is($? >> 8, 0); + is @res, 1; + my $result = decode_json $res[0]; + + is(@$result, 2); + ok($_ ~~ ['SUB.FOLDER', 'SENT']) for @$result; +}; + +subtest count => sub { + my @res = `$PROG count ''`; + + is($? >> 8, 0); + is @res, 1; + my $result = decode_json $res[0]; + + is($result->{count}, 2); + #is($result->{new}, 0); +}; + +subtest list => sub { + my @res = `$PROG list 0 10 date ''`; + + is($? >> 8, 0); + is @res, 1; + my $result = decode_json $res[0]; + + is(@$result, 2); + ok($result->[0]{mid}); + ok($result->[0]{from}); + ok($result->[0]{to}); +}; + +subtest read => sub { + my @pre_res = `$PROG list 0 10 date ''`; + + is($? >> 8, 0); + is @pre_res, 1; + my $pre_result = decode_json $pre_res[0]; + ok(my $mid = $pre_result->[0]{mid}); + + my @res = `$PROG read-mail '$mid'`; + + is($? >> 8, 0); + is @res, 1; + my $result = decode_json $res[0]; + + is($result->{from}, 'test'); +}; + +done_testing; |