diff options
author | Eric Wong <e@80x24.org> | 2015-09-18 01:37:53 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-09-18 21:23:53 +0000 |
commit | 761736a312a103ba522abac52a604564f9e788ce (patch) | |
tree | 283a952c417d4be4573e1e26a9b546e0b1fdadf6 /t/msgmap.t | |
parent | 62ee3cb36dd08f17e444e96dc80108464ee10cba (diff) | |
download | public-inbox-761736a312a103ba522abac52a604564f9e788ce.tar.gz |
Implementing NEWNEWS, XHDR, XOVER efficiently will require additional caching on top of msgmap. This seems to work with lynx and slrnpull, haven't tried clients. DO NOT run in production, yet, denial-of-service vulnerabilities await!
Diffstat (limited to 't/msgmap.t')
-rw-r--r-- | t/msgmap.t | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -12,6 +12,8 @@ my $d = PublicInbox::Msgmap->new($tmpdir, 1); my %mid2num; my %num2mid; my @mids = qw(a@b c@d e@f g@h aa@bb aa@cc); +is_deeply([$d->minmax], [undef,undef], "empty min max on new DB"); + foreach my $mid (@mids) { my $n = $d->mid_insert($mid); ok($n, "mid $mid inserted"); @@ -23,6 +25,7 @@ $@ = undef; eval { $d->mid_insert('a@b') }; ok($@, 'error raised when attempting duplicate message ID'); + foreach my $n (keys %num2mid) { is($d->mid_for($n), $num2mid{$n}, "num:$n maps correctly"); } @@ -47,7 +50,14 @@ is($d->mid_delete('a@b') + 0, 0, 'delete again returns zero'); is(undef, $d->num_for('a@b'), 'num_for fails on deleted msg'); $d = undef; -# idempotent -ok(PublicInbox::Msgmap->new($tmpdir, 1), 'idempotent DB creation'); +ok($d = PublicInbox::Msgmap->new($tmpdir, 1), 'idempotent DB creation'); +my ($min, $max) = $d->minmax; +ok($min > 0, "article min OK"); +ok($max > 0 && $max < 10, "article max OK"); +ok($min < $max, "article counts OK"); + +my $orig = $d->mid_insert('spam@1'); +$d->mid_delete('spam@1'); +is($d->mid_insert('spam@2'), 1 + $orig, "last number not recycled"); done_testing(); |