X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Finbox_idle.t;h=51379764f2703882232e0676c09a39208c7c71eb;hb=c2b4e6111a561095d5155402d6900dae09b704eb;hp=27facfe9276a70658397058d1e17743008dd4e34;hpb=9dfc0b670fc634b54998c3020f173b82de1915ac;p=public-inbox.git
diff --git a/t/inbox_idle.t b/t/inbox_idle.t
index 27facfe9..51379764 100644
--- a/t/inbox_idle.t
+++ b/t/inbox_idle.t
@@ -1,41 +1,35 @@
#!perl -w
# Copyright (C) 2020-2021 all contributors
# License: AGPL-3.0+
-use Test::More;
+use strict;
+use v5.10.1;
use PublicInbox::TestCommon;
use PublicInbox::Config;
require_git 2.6;
require_mods(qw(DBD::SQLite));
require PublicInbox::SearchIdx;
use_ok 'PublicInbox::InboxIdle';
-use PublicInbox::InboxWritable;
my ($tmpdir, $for_destroy) = tmpdir();
for my $V (1, 2) {
my $inboxdir = "$tmpdir/$V";
- mkdir $inboxdir or BAIL_OUT("mkdir: $!");
- my %opt = (
- inboxdir => $inboxdir,
- name => 'inbox-idle',
- version => $V,
- -primary_address => 'test@example.com',
- indexlevel => 'basic',
- );
- my $ibx = PublicInbox::Inbox->new({ %opt });
- $ibx = PublicInbox::InboxWritable->new($ibx);
- my $obj = InboxIdleTestObj->new;
- $ibx->init_inbox(0);
- my $im = $ibx->importer(0);
- if ($V == 1) {
+ my $ibx = create_inbox "idle$V", tmpdir => $inboxdir, version => $V,
+ indexlevel => 'basic', -no_gc => 1, sub {
+ my ($im, $ibx) = @_; # capture
+ $im->done;
+ $ibx->init_inbox(0);
+ $_[0] = undef;
+ return if $V != 1;
my $sidx = PublicInbox::SearchIdx->new($ibx, 1);
$sidx->idx_acquire;
$sidx->set_metadata_once;
$sidx->idx_release; # allow watching on lockfile
- }
+ };
+ my $obj = InboxIdleTestObj->new;
my $pi_cfg = PublicInbox::Config->new(\<{-primary_address}
EOF
my $ident = 'whatever';
$pi_cfg->each_inbox(sub { shift->subscribe_unlock($ident, $obj) });
@@ -45,15 +39,14 @@ EOF
skip('inotify or kqueue missing', 1) unless $ii->{sock};
ok(fileno($ii->{sock}) >= 0, 'fileno() gave valid FD');
}
+ my $im = $ibx->importer(0);
ok($im->add(eml_load('t/utf8.eml')), "$V added");
$im->done;
- PublicInbox::SearchIdx->new($ibx)->index_sync if $V == 1;
$ii->event_step;
is(scalar @{$obj->{called}}, 1, 'called on unlock');
$pi_cfg->each_inbox(sub { shift->unsubscribe_unlock($ident) });
ok($im->add(eml_load('t/data/0001.patch')), "$V added #2");
$im->done;
- PublicInbox::SearchIdx->new($ibx)->index_sync if $V == 1;
$ii->event_step;
is(scalar @{$obj->{called}}, 1, 'not called when unsubbed');
$ii->close;