X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Freplace.t;h=c4dcb89dec1673f02def9001d299e6f71e14dd19;hb=1e3c53a422b8d23cff961e43f77ea0a835cdef78;hp=57290f96edccef4e17db2be2b93a74dfb9e74058;hpb=a995291288a350f426890e57e0bc4a6041c3c8ed;p=public-inbox.git diff --git a/t/replace.t b/t/replace.t index 57290f96..c4dcb89d 100644 --- a/t/replace.t +++ b/t/replace.t @@ -1,18 +1,14 @@ -# Copyright (C) 2019 all contributors +# Copyright (C) 2019-2020 all contributors # License: AGPL-3.0+ use strict; use warnings; use Test::More; -use PublicInbox::MIME; +use PublicInbox::Eml; use PublicInbox::InboxWritable; -require './t/common.perl'; +use PublicInbox::TestCommon; use Cwd qw(abs_path); require_git(2.6); # replace is v2 only, for now... -foreach my $mod (qw(DBD::SQLite)) { - eval "require $mod"; - plan skip_all => "$mod missing for $0" if $@; -} - +require_mods(qw(DBD::SQLite)); local $ENV{HOME} = abs_path('t'); sub test_replace ($$$) { @@ -28,7 +24,7 @@ sub test_replace ($$$) { indexlevel => $level, }); - my $orig = PublicInbox::MIME->new(<<'EOF'); + my $orig = PublicInbox::Eml->new(<<'EOF'); From: Barbra Streisand To: test@example.com Subject: confidential @@ -37,7 +33,7 @@ Date: Fri, 02 Oct 1993 00:00:00 +0000 Top secret info about my house in Malibu... EOF - my $im = PublicInbox::InboxWritable->new($ibx, {nproc=>1})->importer; + my $im = PublicInbox::InboxWritable->new($ibx, {nproc=>1})->importer(0); # fake a bunch of epochs $im->{rotate_bytes} = $opt->{rotate_bytes} if $opt->{rotate_bytes}; @@ -53,7 +49,7 @@ EOF my $thread_a = $ibx->over->get_thread('replace@example.com'); my %before = map {; delete($_->{blob}) => $_ } @{$ibx->recent}; - my $reject = PublicInbox::MIME->new($orig->as_string); + my $reject = PublicInbox::Eml->new($orig->as_string); foreach my $mid (['', ''], [], ['']) { $reject->header_set('Message-ID', @$mid); @@ -65,7 +61,7 @@ EOF # prepare the replacement my $expect = "Move along, nothing to see here\n"; - my $repl = PublicInbox::MIME->new($orig->as_string); + my $repl = PublicInbox::Eml->new($orig->as_string); $repl->header_set('From', ''); $repl->header_set('Subject', 'redacted'); $repl->header_set('Date', 'Sat, 02 Oct 2010 00:00:00 +0000'); @@ -84,7 +80,7 @@ EOF is($changed_epochs, 1, 'only one epoch changed'); $im->done; - my $m = PublicInbox::MIME->new($ibx->msg_by_mid('replace@example.com')); + my $m = PublicInbox::Eml->new($ibx->msg_by_mid('replace@example.com')); is($m->body, $expect, 'replaced message'); is_deeply(\@warn, [], 'no warnings on noop'); @@ -99,7 +95,7 @@ EOF for my $dir (glob("$ibx->{inboxdir}/git/*.git")) { my ($bn) = ($dir =~ m!([^/]+)\z!); - is(system(qw(git --git-dir), $dir, + is(xsys(qw(git --git-dir), $dir, qw(fsck --strict --no-progress)), 0, "git fsck is clean in epoch $bn"); } @@ -149,10 +145,12 @@ EOF is($smsg->{subject}, 'redacted', 'after subject'); is($smsg->{mid}, 'replace@example.com', 'before MID'); } + # $git->cleanup; # needed if $im->{parallel}; @warn = (); is($im->replace($orig, $repl), undef, 'no-op replace returns undef'); is($im->purge($orig), undef, 'no-op purge returns undef'); is_deeply(\@warn, [], 'no warnings on noop'); + # $im->done; # needed if $im->{parallel} } sub pad_msgs { @@ -163,7 +161,7 @@ sub pad_msgs { ($i, $irt) = each %$i; } my $sec = sprintf('%0d', $i); - my $mime = PublicInbox::MIME->new(<new(<