[pve-devel] [PATCH container 1/5] test: mock PVE::Cluster in setup tests
Fabian Grünbichler
f.gruenbichler at proxmox.com
Wed Nov 6 13:36:48 CET 2019
Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
src/test/run_setup_tests.pl | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/src/test/run_setup_tests.pl b/src/test/run_setup_tests.pl
index 678ff0f..bb66c01 100755
--- a/src/test/run_setup_tests.pl
+++ b/src/test/run_setup_tests.pl
@@ -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) {
--
2.20.1
More information about the pve-devel
mailing list