]> git.proxmox.com Git - pve-container.git/commitdiff
test: mock PVE::Cluster in setup tests
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Wed, 6 Nov 2019 12:36:48 +0000 (13:36 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 8 Nov 2019 10:23:41 +0000 (11:23 +0100)
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
src/test/run_setup_tests.pl

index 678ff0f7e8c783c78f6c095f5215f8a3dfb260d6..bb66c016fd23865d07c979e9c6ba8f54a4005b73 100755 (executable)
@@ -2,6 +2,9 @@
 
 use strict;
 use warnings;
+
+use Test::MockModule;
+
 use PVE::Tools qw(run_command);
 
 use lib qw(..);
@@ -100,6 +103,21 @@ sub run_test {
     print "TEST $testdir => OK\n";
 }
 
+my $cluster_module = Test::MockModule->new("PVE::Cluster");
+$cluster_module->mock(
+    cfs_read_file => sub {
+       my ($filename) = @_;
+       return {} if $filename eq 'datacenter.cfg';
+       die "illegal access to pmxcfs in test!\n";
+    },
+    cfs_write_file => sub {
+       die "illegal access to pmxcfs in test!\n";
+    },
+    cfs_lock_file => sub {
+       die "illegal access to pmxcfs in test!\n";
+    },
+);
+
 if (scalar(@ARGV)) {
 
     foreach my $testdir (@ARGV) {