+{
+ my @new = glob("$faildir/new/*");
+ is_deeply(\@new, [], 'nothing in faildir');
+ local $ENV{PATH} = $fail_path;
+ $mime->header_set('Message-ID', '<bar@foo>');
+ ok($tmp->sysseek(0, SEEK_SET) &&
+ $tmp->truncate(0) &&
+ $tmp->print($mime->as_string) &&
+ $tmp->flush &&
+ $tmp->sysseek(0, SEEK_SET),
+ 'rewound and rewrite temporary file');
+ my $cmd = ['public-inbox-mda'];
+ ok(PublicInbox::Import::run_die($cmd, 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('');
+ is(scalar(@$msgs), 1, 'no new message');
+
+ my $config = "$ENV{PI_DIR}/config";
+ ok(-f $config, 'config exists');
+ my $k = 'publicinboxmda.spamcheck';
+ is(system('git', 'config', "--file=$config", $k, 'none'), 0,
+ 'disabled spamcheck for mda');
+ ok($tmp->sysseek(0, SEEK_SET), 'rewound input file');
+
+ ok(PublicInbox::Import::run_die($cmd, 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('');
+ is(scalar(@$msgs), 2, 'new message added OK');
+}
+
+{
+ my $patch = 't/data/0001.patch';
+ open my $fh, '<', $patch or die "failed to open $patch: $!\n";
+ $rdr = { 0 => fileno($fh) };
+ ok(PublicInbox::Import::run_die(['public-inbox-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');
+ is($post->[0]->{blob}, $pre->[0]->{blob}, 'same message in both cases');
+}
+