X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Faltid.t;h=d4f6152e302651e34825d2e65a6c6dde5da5eb6a;hb=69329215485cf2ab9d8cd1fa7faf65d8ec42dc0b;hp=887d548f4b668a6c32a53e16f12acdb363767be9;hpb=58a5bb3e18901237b1ca34ef8f03f696be27d305;p=public-inbox.git
diff --git a/t/altid.t b/t/altid.t
index 887d548f..d4f6152e 100644
--- a/t/altid.t
+++ b/t/altid.t
@@ -1,4 +1,4 @@
-# Copyright (C) 2016 all contributors
+# Copyright (C) 2016-2018 all contributors
# License: AGPL-3.0+
use strict;
use warnings;
@@ -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');
}
{
@@ -48,14 +50,20 @@ my $altid = [ "serial:gmane:file=$alt_file" ];
{
my $ro = PublicInbox::Search->new($git_dir, $altid);
- my $res = $ro->query("gmane:1234");
- is($res->{total}, 1, 'got one match');
- is($res->{msgs}->[0]->mid, 'a@example.com');
+ my $msgs = $ro->query("gmane:1234");
+ is_deeply([map { $_->mid } @$msgs], ['a@example.com'], 'got one match');
- $res = $ro->query("gmane:666");
- is($res->{total}, 0, 'body did NOT match');
+ $msgs = $ro->query("gmane:666");
+ is_deeply([], $msgs, '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;