]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/v2writable.t
v2writable: implement remove correctly
[public-inbox.git] / t / v2writable.t
index 7d276da7091fb18f9db73930e4e36a3e89634960..6e37b722aa19496ce4b90ed22f804696618c8cf5 100644 (file)
@@ -36,12 +36,13 @@ my $im = eval {
 };
 is($im->{partitions}, 1, 'one partition when forced');
 ok($im->add($mime), 'ordinary message added');
+my $git0;
 
 if ('ensure git configs are correct') {
        my @cmd = (qw(git config), "--file=$mainrepo/all.git/config",
                qw(core.sharedRepository 0644));
        is(system(@cmd), 0, "set sharedRepository in all.git");
-       my $git0 = PublicInbox::Git->new("$mainrepo/git/0.git");
+       $git0 = PublicInbox::Git->new("$mainrepo/git/0.git");
        my $fh = $git0->popen(qw(config core.sharedRepository));
        my $v = eval { local $/; <$fh> };
        chomp $v;
@@ -189,8 +190,23 @@ EOF
 };
 {
        local $ENV{NPROC} = 2;
+       my @before = $git0->qx(qw(log --pretty=oneline));
        $im = PublicInbox::V2Writable->new($ibx, 1);
        is($im->{partitions}, 1, 'detected single partition from previous');
+       my $smsg = $im->remove($mime, 'test removal');
+       my @after = $git0->qx(qw(log --pretty=oneline));
+       $im->done;
+       my $tip = shift @after;
+       like($tip, qr/\A[a-f0-9]+ test removal\n\z/s,
+               'commit message propaged to git');
+       is_deeply(\@after, \@before, 'only one commit written to git');
+       is($ibx->mm->num_for($smsg->mid), undef, 'no longer in Msgmap by mid');
+       like($smsg->num, qr/\A\d+\z/, 'numeric number in return message');
+       is($ibx->mm->mid_for($smsg->num), undef, 'no longer in Msgmap by num');
+       my $srch = $ibx->search->reopen;
+       my @found = ();
+       $srch->each_smsg_by_mid($smsg->mid, sub { push @found, @_; 1 });
+       is(scalar(@found), 0, 'no longer found in Xapian skeleton');
 }
 
 done_testing();