test: unbreak restore_config_test

for unprivileged users (and possibly some root setups). reading from
pmxcfs now results in a hard error for unprivileged users, so there
might be some more of these lurking somewhere..

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2021-06-04 11:47:43 +02:00 committed by Thomas Lamprecht
parent 872cfcf5bc
commit 75c430cee8

View File

@ -7,6 +7,7 @@ use lib qw(..);
use Test::MockModule;
use Test::More;
use Test::MockModule;
use File::Basename;
@ -26,6 +27,19 @@ $pve_cluster_module->mock(
# NOTE update when you add/remove tests
plan tests => 4;
my $cfs_mock = Test::MockModule->new("PVE::Cluster");
$cfs_mock->mock(
cfs_read_file => sub {
my ($file) = @_;
if ($file eq 'datacenter.cfg') {
return {};
} else {
die "'cfs_read_file' called - missing mock?\n";
}
},
);
dir_glob_foreach('./restore-config-input', '[0-9]+.conf', sub {
my ($file) = @_;