X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fshared_kv.t;h=251b7f3942c88eceb36785f5e486fbdd4fb58cdf;hb=7ffa98cbbf5bff8225fdfedb0f2b7c2beb5d0a6f;hp=ad901328360bfa3e755cd7d2d951eb2dfbbd700c;hpb=a7539312d51443c9a705e64b16ac4fdcd4b17a6e;p=public-inbox.git diff --git a/t/shared_kv.t b/t/shared_kv.t index ad901328..251b7f39 100644 --- a/t/shared_kv.t +++ b/t/shared_kv.t @@ -1,17 +1,17 @@ #!perl -w -# Copyright (C) 2020 all contributors +# Copyright (C) 2020-2021 all contributors # License: AGPL-3.0+ use strict; use v5.10.1; use Test::More; use PublicInbox::TestCommon; +require_mods(qw(DBD::SQLite)); use_ok 'PublicInbox::SharedKV'; my ($tmpdir, $for_destroy) = tmpdir(); local $ENV{TMPDIR} = $tmpdir; my $skv = PublicInbox::SharedKV->new; -opendir(my $dh, $tmpdir) or BAIL_OUT $!; -my @ent = grep(!/\A\.\.?\z/, readdir($dh)); -is(scalar(@ent), 1, 'created a temporary dir'); +my $skv_tmpdir = $skv->{"tmp$$.$skv"}; +ok(-d $skv_tmpdir, 'created a temporary dir'); $skv->dbh; my $dead = "\xde\xad"; my $beef = "\xbe\xef"; @@ -48,10 +48,7 @@ is($skv->delete_by_val($dead), 2, 'delete_by_val hits'); is($skv->delete_by_val($dead), 0, 'delete_by_val misses again'); undef $skv; -rewinddir($dh); -@ent = grep(!/\A\.\.?\z/, readdir($dh)); -is(scalar(@ent), 0, 'temporary dir gone'); -undef $dh; +ok(!-d $skv_tmpdir, 'temporary dir gone'); $skv = PublicInbox::SharedKV->new("$tmpdir/dir", 'base'); ok(-e "$tmpdir/dir/base.sqlite3", 'file created');