X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Freplace.t;h=cef4e7aa6cbe6e57ebaed2c5998a436f62b43f38;hb=0283273a14e1871955f6a9132f4f3f7884ec8a3f;hp=6fae551167ac390658ddee25c0f2278b9cba3dad;hpb=d9aad3a7988262b31ab2171f2c982daf04ac822c;p=public-inbox.git diff --git a/t/replace.t b/t/replace.t index 6fae5511..cef4e7aa 100644 --- a/t/replace.t +++ b/t/replace.t @@ -1,32 +1,30 @@ -# 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; -use File::Temp qw/tempdir/; -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 ($$$) { my ($v, $level, $opt) = @_; diag "v$v $level replace"; my $this = "pi-$v-$level-replace"; - my $tmpdir = tempdir("$this-tmp-XXXXXX", TMPDIR => 1, CLEANUP => 1); + my ($tmpdir, $for_destroy) = tmpdir($this); my $ibx = PublicInbox::Inbox->new({ - mainrepo => "$tmpdir/testbox", + inboxdir => "$tmpdir/testbox", name => $this, version => $v, -primary_address => 'test@example.com', indexlevel => $level, }); - my $orig = PublicInbox::MIME->new(<<'EOF'); + my $orig = PublicInbox::Eml->new(<<'EOF'); From: Barbra Streisand To: test@example.com Subject: confidential @@ -51,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); @@ -63,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'); @@ -82,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'); @@ -95,10 +93,11 @@ EOF my $t19931002 = qr/ 749520000 /; is_deeply([grep(/$t19931002/, @all)], [], "nothing matches $t19931002"); - for my $dir (glob("$ibx->{mainrepo}/git/*.git")) { + for my $dir (glob("$ibx->{inboxdir}/git/*.git")) { my ($bn) = ($dir =~ m!([^/]+)\z!); - is(system(qw(git --git-dir), $dir, qw(fsck --strict)), 0, - "git fsck is clean in epoch $bn"); + is(xsys(qw(git --git-dir), $dir, + qw(fsck --strict --no-progress)), + 0, "git fsck is clean in epoch $bn"); } my $thread_b = $ibx->over->get_thread('replace@example.com'); @@ -160,7 +159,7 @@ sub pad_msgs { ($i, $irt) = each %$i; } my $sec = sprintf('%0d', $i); - my $mime = PublicInbox::MIME->new(<new(< @@ -184,7 +183,7 @@ test_replace(2, 'basic', $opt); test_replace(2, 'basic', $opt = { %$opt, post => *pad_msgs }); test_replace(2, 'basic', $opt = { %$opt, rotate_bytes => 1 }); -SKIP: if ('test xapian') { +SKIP: { require PublicInbox::Search; PublicInbox::Search::load_xapian() or skip 'Search::Xapian missing', 8; for my $l (qw(medium)) {