File: 05_pseudohome.t

package info (click to toggle)
libfile-save-home-perl 0.09-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 188 kB
  • ctags: 12
  • sloc: perl: 182; makefile: 11
file content (59 lines) | stat: -rw-r--r-- 1,516 bytes parent folder | download
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# t/05_pseudohome.t
use strict;
use warnings;

use Test::More 
# tests =>  9;
qw(no_plan);

use_ok('File::Save::Home', qw|
    get_subhome_directory_status
    make_subhome_temp_directory 
| );
use_ok('File::Temp', qw| tempdir |);
use_ok('Cwd');
use_ok ( 'String::Random', qw(random_regex) );
*make_varname = sub { return random_regex(q([a-z]{10})) };

my ($cwd, $pseudohome, $desired_dir_ref );
$cwd = cwd();

ok($pseudohome = tempdir( CLEANUP => 1 ), 
    'pseudo-home directory has been created');

ok(chdir $pseudohome, "able to change to $pseudohome");

$desired_dir_ref = get_subhome_directory_status(
    make_varname(),
    $pseudohome,
);
ok(! defined $desired_dir_ref->{flag}, 
    "random directory name $desired_dir_ref->{abs} is undefined");

ok(chdir $cwd, "able to change to $cwd");

eval {
    $desired_dir_ref = get_subhome_directory_status(
        make_varname(),
        make_varname(),
    );
};
like($@, qr/is\snot\sa\svalid\sdirectory/,
    "optional second argument must be a valid directory");

my ($newpseudohome, $tmpdir);
ok($newpseudohome = tempdir( CLEANUP => 1 ), 
    'another pseudo-home directory has been created');

ok(chdir $newpseudohome, "able to change to $newpseudohome");

$tmpdir = make_subhome_temp_directory($newpseudohome);
ok(  (-d $tmpdir), "$tmpdir exists");

ok(chdir $cwd, "able to change to $cwd");

eval {
    $tmpdir = make_subhome_temp_directory(make_varname());
};
like($@, qr/is\snot\sa\svalid\sdirectory/,
    "optional argument must be a valid directory");