File: 004_create.t

package info (click to toggle)
libdirectory-scratch-structured-perl 0.04-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 108 kB
  • sloc: perl: 62; makefile: 2
file content (69 lines) | stat: -r-xr-xr-x 1,322 bytes parent folder | download | duplicates (4)
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
60
61
62
63
64
65
66
67
68
69
# test

use strict ;
use warnings ;

use Test::Exception ;
use Test::Warn;
use Test::NoWarnings ;

use Test::More 'no_plan';
use Test::Block qw($Plan);

use Directory::Scratch::Structured qw(create_structured_tree piggyback_directory_scratch) ; 

my %tree_structure =
	(
	file_0 => [] ,
	
	dir_1 =>
		{
		subdir_1 =>{},
		file_1 =>[],
		file_a => [],
		},
		
	dir_2 =>
		{
		subdir_2 =>
			{
			file_22 =>[],
			file_2a =>[],
			},
		file_2 =>[],
		file_a =>['12345'],
		file_b =>[],
		},
	) ;

my $base ;

{
local $Plan = {'non OO interface' => 5} ;

my $temporary_directory = create_structured_tree(%tree_structure) ;
$base = $temporary_directory->base() ;

ok(-e "$base/file_0", "file created") ;
ok(-e "$base/dir_1", "directory created") ;
ok(-e "$base/dir_1/subdir_1", "sub directory created") ;
ok(-e "$base/dir_1/file_1", "directory file created") ;

is(-s "$base/dir_2/file_a", 6, "sub directory file size ok") ;
}

{
local $Plan = {'OO interface' => 5} ;

my $scratch = Directory::Scratch->new;
$scratch->create_structured_tree(%tree_structure) ;

ok(-e "$base/file_0", "file created") ;
ok(-e "$base/dir_1", "directory created") ;
ok(-e "$base/dir_1/subdir_1", "sub directory created") ;
ok(-e "$base/dir_1/file_1", "directory file created") ;

is(-s "$base/dir_2/file_a", 6, "sub directory file size ok") ;
}