1 # Copyright (C) 2018 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
6 use File::Temp qw/tempdir/;
7 foreach my $mod (qw(DBD::SQLite)) {
9 plan skip_all => "$mod missing for over.t" if $@;
12 use_ok 'PublicInbox::OverIdx';
13 my $tmpdir = tempdir('pi-over-XXXXXX', TMPDIR => 1, CLEANUP => 1);
14 my $over = PublicInbox::OverIdx->new("$tmpdir/over.sqlite3");
16 my $x = $over->next_tid;
17 is(int($x), $x, 'integer tid');
18 my $y = $over->next_tid;
19 is($y, $x+1, 'tid increases');
21 $x = $over->sid('hello-world');
22 is(int($x), $x, 'integer sid');
23 $y = $over->sid('hello-WORLD');
24 is($y, $x+1, 'sid ncreases');
25 is($over->sid('hello-world'), $x, 'idempotent');
28 $over = PublicInbox::OverIdx->new("$tmpdir/over.sqlite3");
30 is($over->sid('hello-world'), $x, 'idempotent across reopen');
31 $over->each_by_mid('never', sub { fail('should not be called') });
33 $x = $over->create_ghost('never');
34 is(int($x), $x, 'integer tid for ghost');
35 $y = $over->create_ghost('NEVAR');
36 is($y, $x + 1, 'integer tid for ghost increases');