File: tmp_dir.t

package info (click to toggle)
libtest-redisserver-perl 0.21-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 188 kB
  • sloc: perl: 171; makefile: 11; sh: 4
file content (36 lines) | stat: -rw-r--r-- 805 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use strict;
use warnings;
use File::Temp;
use Test::More;
use Test::TCP;

use Test::RedisServer;

eval { Test::RedisServer->new } or plan skip_all => 'redis-server is required in PATH to run this test';

my $tmp_dir = File::Temp->newdir( CLEANUP => 1 );

my $tmp_root_dir = File::Spec->tmpdir();

my @initial_files = <$tmp_root_dir/*>;
my $initial_children_count = @initial_files;

$ENV{TMPDIR} = $tmp_root_dir;

my $server = Test::TCP->new(
    code => sub {
        my $port = shift;
        Test::RedisServer->new(
            auto_start => 0,
            tmpdir     => $tmp_dir,
            conf       => { port => $port },
        )->exec;
    }
);

$server = undef;

my @files = <$tmp_root_dir/*>;
is scalar @files, $initial_children_count, "no files remained after server shutdown";

done_testing;