]> Sergey Matveev's repositories - public-inbox.git/commitdiff
t/altid_v2: improve test style
authorEric Wong <e@80x24.org>
Fri, 30 Sep 2022 09:21:40 +0000 (09:21 +0000)
committerEric Wong <e@80x24.org>
Fri, 30 Sep 2022 16:25:07 +0000 (16:25 +0000)
Favor `is' for equality checks since it reports differences,
and `xbail' over `BAIL_OUT' since it's easier-to-type w/o caps
and more powerful.

These are just things noticed while I was looking at another
odd failure on CentOS 7.x with this test, but I suspect it
was a transient failure caused by running the test suite
from multiple terminals in parallel.

t/altid_v2.t

index 281a09d51dd0cfe4af5ed0b5590ec97b8a74b68c..c62252c1494a4a11daa01280f7c08e3d6a3b689d 100644 (file)
@@ -14,9 +14,9 @@ my $ibx = create_inbox 'v2', version => 2, indexlevel => 'medium',
                        altid => $altid, sub {
        my ($im, $ibx) = @_;
        my $mm = PublicInbox::Msgmap->new_file("$ibx->{inboxdir}/$another", 2);
-       $mm->mid_set(1234, 'a@example.com') == 1 or BAIL_OUT 'mid_set once';
-       ok(0 == $mm->mid_set(1234, 'a@example.com'), 'mid_set not idempotent');
-       ok(0 == $mm->mid_set(1, 'a@example.com'), 'mid_set fails with dup MID');
+       is($mm->mid_set(1234, 'a@example.com'), 1, 'mid_set') or xbail 'once';
+       is($mm->mid_set(1234, 'a@example.com')+0, 0, 'mid_set not idempotent');
+       is($mm->mid_set(1, 'a@example.com')+0, 0, 'mid_set fails with dup MID');
        $im->add(PublicInbox::Eml->new(<<'EOF')) or BAIL_OUT;
 From: a@example.com
 To: b@example.com
@@ -27,8 +27,8 @@ hello world gmane:666
 EOF
 };
 my $mm = PublicInbox::Msgmap->new_file("$ibx->{inboxdir}/$another", 2);
-ok(0 == $mm->mid_set(1234, 'a@example.com'), 'mid_set not idempotent');
-ok(0 ==  $mm->mid_set(1, 'a@example.com'), 'mid_set fails with dup MID');
+is($mm->mid_set(1234, 'a@example.com') + 0, 0, 'mid_set not idempotent');
+is($mm->mid_set(1, 'a@example.com') + 0, 0, 'mid_set fails with dup MID');
 my $mset = $ibx->search->mset('gmane:1234');
 my $msgs = $ibx->search->mset_to_smsg($ibx, $mset);
 $msgs = [ map { $_->{mid} } @$msgs ];