diff options
author | Eric Wong <e@80x24.org> | 2021-02-18 23:22:23 +0300 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-02-18 20:02:19 -0400 |
commit | 46eac797d44b068a5e144ecc8269e9dbe878f495 (patch) | |
tree | ab982a011384c6ae14ba4e4d9e292c9ed6027479 /t/lei-import-imap.t | |
parent | 63283ae1b51203c930332e6887296cb123e5db6c (diff) | |
download | public-inbox-46eac797d44b068a5e144ecc8269e9dbe878f495.tar.gz |
This makes "lei import" more similar to "lei convert" and allows importing from disparate sources simultaneously. We'll also fix some ->child_error usage errors and make the style of the code more similar to the "lei convert" code. v2: fix missing requires
Diffstat (limited to 't/lei-import-imap.t')
-rw-r--r-- | t/lei-import-imap.t | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/t/lei-import-imap.t b/t/lei-import-imap.t new file mode 100644 index 00000000..ee308723 --- /dev/null +++ b/t/lei-import-imap.t @@ -0,0 +1,28 @@ +#!perl -w +# Copyright (C) 2021 all contributors <meta@public-inbox.org> +# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt> +use strict; use v5.10.1; use PublicInbox::TestCommon; +require_git 2.6; +require_mods(qw(DBD::SQLite Search::Xapian)); +my ($ro_home, $cfg_path) = setup_public_inboxes; +my ($tmpdir, $for_destroy) = tmpdir; +my $sock = tcp_server; +my $cmd = [ '-imapd', '-W0', "--stdout=$tmpdir/1", "--stderr=$tmpdir/2" ]; +my $env = { PI_CONFIG => $cfg_path }; +my $td = start_script($cmd, $env, { 3 => $sock }) or BAIL_OUT("-imapd: $?"); +my $host_port = tcp_host_port($sock); +undef $sock; +test_lei({ tmpdir => $tmpdir }, sub { + lei_ok(qw(q bytes:1..)); + my $out = json_utf8->decode($lei_out); + is_deeply($out, [ undef ], 'nothing imported, yet'); + lei_ok('import', "imap://$host_port/t.v2.0"); + lei_ok(qw(q bytes:1..)); + $out = json_utf8->decode($lei_out); + ok(scalar(@$out) > 1, 'got imported messages'); + is(pop @$out, undef, 'trailing JSON null element was null'); + my %r; + for (@$out) { $r{ref($_)}++ } + is_deeply(\%r, { 'HASH' => scalar(@$out) }, 'all hashes'); +}); +done_testing; |