about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-03-19 08:14:47 +0000
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-03-19 08:16:34 +0000
commit54f318f413d0fdf8a9d488a19c66b85697312ca0 (patch)
tree74fae5ee0c79e36962901500adf16b84763104bc /t
parent12c3eb5b2b0860292a32d5743ea0157996e9a4b9 (diff)
downloadpublic-inbox-54f318f413d0fdf8a9d488a19c66b85697312ca0.tar.gz
Hexdigests are too long and shorter Message-IDs are easier
to deal with.
Diffstat (limited to 't')
-rw-r--r--t/v2writable.t10
1 files changed, 6 insertions, 4 deletions
diff --git a/t/v2writable.t b/t/v2writable.t
index c6bcefd4..bbe6d14b 100644
--- a/t/v2writable.t
+++ b/t/v2writable.t
@@ -68,6 +68,7 @@ if ('ensure git configs are correct') {
                 [ $mime->header_obj->header_raw('Message-Id') ],
                 'no new Message-Id added');
 
+        my $sane_mid = qr/\A<[\w\-]+\@localhost>\z/;
         @warn = ();
         $mime->header_set('Message-Id', '<a-mid@b>');
         $mime->body_set('different');
@@ -75,13 +76,14 @@ if ('ensure git configs are correct') {
         like(join(' ', @warn), qr/reused/, 'warned about reused MID');
         my @mids = $mime->header_obj->header_raw('Message-Id');
         is($mids[1], '<a-mid@b>', 'original mid not changed');
-        like($mids[0], qr/\A<\w+\@localhost>\z/, 'new MID added');
+        like($mids[0], $sane_mid, 'new MID added');
         is(scalar(@mids), 2, 'only one new MID added');
 
         @warn = ();
         $mime->header_set('Message-Id', '<a-mid@b>');
         $mime->body_set('this one needs a random mid');
-        my $gen = content_digest($mime)->hexdigest . '@localhost';
+        my $gen = PublicInbox::Import::digest2mid(content_digest($mime));
+        unlike($gen, qr![\+/=]!, 'no URL-unfriendly chars in Message-Id');
         my $fake = PublicInbox::MIME->new($mime->as_string);
         $fake->header_set('Message-Id', $gen);
         ok($im->add($fake), 'fake added easily');
@@ -90,14 +92,14 @@ if ('ensure git configs are correct') {
         like(join(' ', @warn), qr/using random/, 'warned about using random');
         @mids = $mime->header_obj->header_raw('Message-Id');
         is($mids[1], '<a-mid@b>', 'original mid not changed');
-        like($mids[0], qr/\A<\w+\@localhost>\z/, 'new MID added');
+        like($mids[0], $sane_mid, 'new MID added');
         is(scalar(@mids), 2, 'only one new MID added');
 
         @warn = ();
         $mime->header_set('Message-Id');
         ok($im->add($mime), 'random MID made for MID free message');
         @mids = $mime->header_obj->header_raw('Message-Id');
-        like($mids[0], qr/\A<\w+\@localhost>\z/, 'mid was generated');
+        like($mids[0], $sane_mid, 'mid was generated');
         is(scalar(@mids), 1, 'new generated');
 }