]>
git.proxmox.com Git - pve-storage.git/blob - test/get_subdir_test.pm
1 package PVE
::Storage
::TestGetSubdir
;
8 use PVE
::Storage
::Plugin
;
11 my $scfg_with_path = { path
=> '/some/path' };
12 my $vtype_subdirs = PVE
::Storage
::Plugin
::get_vtype_subdirs
();
14 # each test is comprised of the following array keys:
15 # [0] => storage config; positive with path key
16 # [1] => storage type; see $vtype_subdirs
17 # [2] => expected return from get_subdir
20 [ $scfg_with_path, 'none', "unknown vtype 'none'\n" ],
21 [ {}, 'iso', "storage definition has no path\n" ],
24 # creates additional positive tests
25 foreach my $type (keys %$vtype_subdirs) {
26 my $path = "$scfg_with_path->{path}/$vtype_subdirs->{$type}";
27 push @$tests, [ $scfg_with_path, $type, $path ];
30 # creates additional tests for overrides
31 foreach my $type (keys %$vtype_subdirs) {
32 my $override = "/${type}_override";
33 my $scfg_with_override = { path
=> '/some/path', dirs
=> { $type => $override } };
34 push @$tests, [ $scfg_with_override, $type, "$scfg_with_override->{path}$scfg_with_override->{dirs}->{$type}" ];
37 plan tests
=> scalar @$tests;
39 foreach my $tt (@$tests) {
40 my ($scfg, $type, $expected) = @$tt;
43 eval { $got = PVE
::Storage
::Plugin-
>get_subdir($scfg, $type) };
46 is ($got, $expected, "get_subdir for $type") || diag
(explain
($got));