X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fover.t;h=5586aa310e6b2318946e25b0c4823e19d3069781;hb=6ebcec3add4d6aeff6e3b3eb019a404528c079ec;hp=7a3c972104d6d15024b8fbc8c5e25465e182e308;hpb=b4404feb5925bae6fc5985894f4c7c2593247eda;p=public-inbox.git diff --git a/t/over.t b/t/over.t index 7a3c9721..5586aa31 100644 --- a/t/over.t +++ b/t/over.t @@ -1,18 +1,13 @@ -# Copyright (C) 2018 all contributors +# Copyright (C) 2018-2020 all contributors # License: AGPL-3.0+ use strict; use warnings; use Test::More; -use File::Temp qw/tempdir/; use Compress::Zlib qw(compress); -# FIXME: allow using Over w/o Xapian -foreach my $mod (qw(DBD::SQLite Search::Xapian)) { - eval "require $mod"; - plan skip_all => "$mod missing for over.t" if $@; -} - +use PublicInbox::TestCommon; +require_mods('DBD::SQLite'); use_ok 'PublicInbox::OverIdx'; -my $tmpdir = tempdir('pi-over-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); my $over = PublicInbox::OverIdx->new("$tmpdir/over.sqlite3"); $over->connect; my $x = $over->next_tid; @@ -23,10 +18,15 @@ is($y, $x+1, 'tid increases'); $x = $over->sid('hello-world'); is(int($x), $x, 'integer sid'); $y = $over->sid('hello-WORLD'); -is($y, $x+1, 'sid ncreases'); +is($y, $x+1, 'sid increases'); is($over->sid('hello-world'), $x, 'idempotent'); +ok(!$over->{dbh}->{ReadOnly}, 'OverIdx is not ReadOnly'); $over->disconnect; +$over = PublicInbox::Over->new("$tmpdir/over.sqlite3"); +$over->connect; +ok($over->{dbh}->{ReadOnly}, 'Over is ReadOnly'); + $over = PublicInbox::OverIdx->new("$tmpdir/over.sqlite3"); $over->connect; is($over->sid('hello-world'), $x, 'idempotent across reopen');