]> Sergey Matveev's repositories - public-inbox.git/blob - t/over.t
replace Xapian skeleton with SQLite overview DB
[public-inbox.git] / t / over.t
1 # Copyright (C) 2018 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
3 use strict;
4 use warnings;
5 use Test::More;
6 use File::Temp qw/tempdir/;
7 foreach my $mod (qw(DBD::SQLite)) {
8         eval "require $mod";
9         plan skip_all => "$mod missing for over.t" if $@;
10 }
11
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");
15 $over->connect;
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');
20
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');
26 $over->disconnect;
27
28 $over = PublicInbox::OverIdx->new("$tmpdir/over.sqlite3");
29 $over->connect;
30 is($over->sid('hello-world'), $x, 'idempotent across reopen');
31 $over->each_by_mid('never', sub { fail('should not be called') });
32
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');
37
38 done_testing();