]> Sergey Matveev's repositories - public-inbox.git/commitdiff
t/altid.t: extra tests for mid_set
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Thu, 22 Mar 2018 03:06:56 +0000 (03:06 +0000)
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Thu, 22 Mar 2018 03:06:56 +0000 (03:06 +0000)
I'll be relying on some of this behavior for regenerating NNTP
article numbers off fresh clones.

t/altid.t

index 7759bd6bc0aea14e5e164fc2e9ff0ac70e910a13..0f3b86c12fee11f6780e5f0f378a15405450b909 100644 (file)
--- a/t/altid.t
+++ b/t/altid.t
@@ -20,7 +20,9 @@ my $altid = [ "serial:gmane:file=$alt_file" ];
 
 {
        my $mm = PublicInbox::Msgmap->new_file($alt_file, 1);
-       $mm->mid_set(1234, 'a@example.com');
+       is($mm->mid_set(1234, 'a@example.com'), 1, 'mid_set once OK');
+       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');
 }
 
 {
@@ -56,6 +58,13 @@ my $altid = [ "serial:gmane:file=$alt_file" ];
        is($res->{total}, 0, 'body did NOT match');
 };
 
+{
+       my $mm = PublicInbox::Msgmap->new_file($alt_file, 1);
+       my ($min, $max) = $mm->minmax;
+       my $num = $mm->mid_insert('b@example.com');
+       ok($num > $max, 'auto-increment goes beyond mid_set');
+}
+
 done_testing();
 
 1;