X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fover.t;h=1f2df7cf065a72a2a4a6e7368e5f53b54010f13d;hb=refs%2Fheads%2Fmaster;hp=6c4c8ee6b0b356b39d7facdf64b03dc63f740f1f;hpb=1814b1a0b78770c8ba9e7a0adef56c4c324d4064;p=public-inbox.git diff --git a/t/over.t b/t/over.t index 6c4c8ee6..1f2df7cf 100644 --- a/t/over.t +++ b/t/over.t @@ -1,4 +1,4 @@ -# Copyright (C) 2018-2020 all contributors +# Copyright (C) 2018-2021 all contributors # License: AGPL-3.0+ use strict; use warnings; @@ -23,7 +23,7 @@ $y = $over->sid('hello-WORLD'); is($y, $x+1, 'sid increases'); is($over->sid('hello-world'), $x, 'idempotent'); ok(!$over->{dbh}->{ReadOnly}, 'OverIdx is not ReadOnly'); -$over->disconnect; +$over->dbh_close; $over = PublicInbox::Over->new("$tmpdir/over.sqlite3"); ok($over->dbh->{ReadOnly}, 'Over is ReadOnly'); @@ -33,9 +33,9 @@ $over->dbh; is($over->sid('hello-world'), $x, 'idempotent across reopen'); $over->each_by_mid('never', sub { fail('should not be called') }); -$x = $over->create_ghost('never'); +$x = $over->resolve_mid_to_tid('never'); is(int($x), $x, 'integer tid for ghost'); -$y = $over->create_ghost('NEVAR'); +$y = $over->resolve_mid_to_tid('NEVAR'); is($y, $x + 1, 'integer tid for ghost increases'); my $ddd = compress(''); @@ -74,4 +74,29 @@ SKIP: { 'WAL journal_mode not clobbered if manually set'); } +# ext index additions +$over->eidx_prep; +{ + my @arg = qw(1349 2019 adeadba7cafe example.key); + ok($over->add_xref3(@arg), 'first add'); + ok($over->add_xref3(@arg), 'add idempotent'); + my $xref3 = $over->get_xref3(1349); + is_deeply($xref3, [ 'example.key:2019:adeadba7cafe' ], 'xref3 works'); + + @arg = qw(1349 2018 deadbeefcafe example.kee); + ok($over->add_xref3(@arg), 'add another xref3'); + $xref3 = $over->get_xref3(1349); + is_deeply($xref3, [ 'example.key:2019:adeadba7cafe', + 'example.kee:2018:deadbeefcafe' ], + 'xref3 works forw two'); + + is($over->dbh->do(<<''), 1, 'remove first'); +DELETE FROM xref3 WHERE xnum = 2019 AND docid = 1349 + + $xref3 = $over->get_xref3(1349); + is_deeply($xref3, [ 'example.kee:2018:deadbeefcafe' ], + 'confirm removal successful'); + $over->rollback_lazy; +} + done_testing();