X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fv2mda.t;h=3dfc569e1dc9b9e7c20a2eeddb6136d045f5c646;hb=7ec7df4c76802f20c30b7b32ccda44b5463e7a7a;hp=4d3ec30db91e4b99ac076826841d53e3e81a2ba0;hpb=e6b7a7f5f70fb89a54ff158bc6c8b564149947e5;p=public-inbox.git diff --git a/t/v2mda.t b/t/v2mda.t index 4d3ec30d..3dfc569e 100644 --- a/t/v2mda.t +++ b/t/v2mda.t @@ -1,4 +1,4 @@ -# Copyright (C) 2018-2020 all contributors +# Copyright (C) 2018-2021 all contributors # License: AGPL-3.0+ use strict; use warnings; @@ -6,7 +6,7 @@ use Test::More; use Fcntl qw(SEEK_SET); use Cwd; use PublicInbox::TestCommon; -use PublicInbox::MIME; +use PublicInbox::Eml; require_git(2.6); my $V = 2; @@ -18,7 +18,7 @@ my $ibx = { name => 'test-v2writable', address => [ 'test@example.com' ], }; -my $mime = PublicInbox::MIME->new(<<'EOF'); +my $mime = PublicInbox::Eml->new(<<'EOF'); From: a@example.com To: test@example.com Subject: this is a subject @@ -46,14 +46,10 @@ local $ENV{ORIGINAL_RECIPIENT} = 'test@example.com'; ok(run_script(['-mda'], undef, $rdr), 'mda delivered a message'); $ibx = PublicInbox::Inbox->new($ibx); - -if ($V == 1) { - ok(run_script([ '-index', "$tmpdir/inbox" ]), 'v1 indexed'); -} -my $msgs = $ibx->search->query(''); +my $msgs = $ibx->over->recent; is(scalar(@$msgs), 1, 'only got one message'); -my $saved = $ibx->smsg_mime($msgs->[0]); -is($saved->{mime}->as_string, $mime->as_string, 'injected message'); +my $eml = $ibx->smsg_eml($msgs->[0]); +is($eml->as_string, $mime->as_string, 'injected message'); { my @new = glob("$faildir/new/*"); @@ -64,7 +60,7 @@ is($saved->{mime}->as_string, $mime->as_string, 'injected message'); ok(run_script(['-mda'], undef, $rdr), 'mda did not die on "spam"'); @new = glob("$faildir/new/*"); is(scalar(@new), 1, 'got a message in faildir'); - $msgs = $ibx->search->reopen->query(''); + $msgs = $ibx->over->recent; is(scalar(@$msgs), 1, 'no new message'); my $config = "$ENV{PI_DIR}/config"; @@ -76,7 +72,7 @@ is($saved->{mime}->as_string, $mime->as_string, 'injected message'); ok(run_script(['-mda'], undef, $rdr), 'mda did not die'); my @again = glob("$faildir/new/*"); is_deeply(\@again, \@new, 'no new message in faildir'); - $msgs = $ibx->search->reopen->query(''); + $msgs = $ibx->over->recent; is(scalar(@$msgs), 2, 'new message added OK'); } @@ -85,10 +81,12 @@ is($saved->{mime}->as_string, $mime->as_string, 'injected message'); open my $fh, '<', $patch or die "failed to open $patch: $!\n"; $rdr->{0} = \(do { local $/; <$fh> }); ok(run_script(['-mda'], undef, $rdr), 'mda delivered a patch'); - my $post = $ibx->search->reopen->query('dfpost:6e006fd7'); - is(scalar(@$post), 1, 'got one result for dfpost'); - my $pre = $ibx->search->query('dfpre:090d998'); - is(scalar(@$pre), 1, 'got one result for dfpre'); + my $post = $ibx->search->reopen->mset('dfpost:6e006fd7'); + is($post->size, 1, 'got one result for dfpost'); + my $pre = $ibx->search->mset('dfpre:090d998'); + is($pre->size, 1, 'got one result for dfpre'); + $pre = $ibx->search->mset_to_smsg($ibx, $pre); + $post = $ibx->search->mset_to_smsg($ibx, $post); is($post->[0]->{blob}, $pre->[0]->{blob}, 'same message in both cases'); }