X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Faltid.t;h=d4f6152e302651e34825d2e65a6c6dde5da5eb6a;hb=e350de7fdbe12dafc36e893e66ce8c93ec6dc3f2;hp=7759bd6bc0aea14e5e164fc2e9ff0ac70e910a13;hpb=3d41aa23f35501ca92aab8aa42980fa73f7fa74f;p=public-inbox.git diff --git a/t/altid.t b/t/altid.t index 7759bd6b..d4f6152e 100644 --- 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'); } { @@ -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;