From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 4/4] t/altid_v2: improve test style
Date: Fri, 30 Sep 2022 09:21:40 +0000 [thread overview]
Message-ID: <20220930092140.3894047-5-e@80x24.org> (raw)
In-Reply-To: <20220930092140.3894047-1-e@80x24.org>
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 | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/t/altid_v2.t b/t/altid_v2.t
index 281a09d5..c62252c1 100644
--- a/t/altid_v2.t
+++ b/t/altid_v2.t
@@ -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 ];
next prev parent reply other threads:[~2022-09-30 9:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-30 9:21 [PATCH 0/4] fixes noticed while diagnosing t/lei-up.t Eric Wong
2022-09-30 9:21 ` [PATCH 1/4] tests: favor 3 argument `open' with interopolation Eric Wong
2022-09-30 9:21 ` [PATCH 2/4] t/lei-up: improve diagnostics for this test Eric Wong
2022-09-30 9:21 ` [PATCH 3/4] lei_to_mail: propagate errors to script/lei Eric Wong
2022-09-30 9:21 ` Eric Wong [this message]
2022-09-30 17:20 ` SQLite <3.8.3 was broken on fork (was: fixes noticed while diagnosing t/lei-up.t) Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220930092140.3894047-5-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).