[pve-devel] [PATCH container v2 1/2] tests: fix small syntax glitch

Stoiko Ivanov s.ivanov at proxmox.com
Wed Jun 14 14:33:24 CEST 2023


adaptation to adhere to perlcritics recommendation led to the snapshot
tests to not work anymore:
```
Undefined subroutine &Test::MockModule called at snapshot-test.pm line 300.
```

With this the snapshot tests still run and perlcritic seems happy

Fixes: f505de300431134b202ad5a88f55721cb95e6fe4
Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
 src/test/snapshot-test.pm | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/test/snapshot-test.pm b/src/test/snapshot-test.pm
index 8e6e9c2..f9b1616 100644
--- a/src/test/snapshot-test.pm
+++ b/src/test/snapshot-test.pm
@@ -297,21 +297,21 @@ PVE::Tools::run_command("cp -a snapshot-input snapshot-working");
 
 printf("\n");
 printf("Setting up Mocking for PVE::LXC and PVE::LXC::Config\n");
-my $lxc_module = Test::MockModule('PVE::LXC')->new();
+my $lxc_module = Test::MockModule->new('PVE::LXC');
 $lxc_module->mock('sync_container_namespace', sub { return; });
 $lxc_module->mock('check_running', \&mocked_check_running);
 $lxc_module->mock('vm_stop', \&mocked_vm_stop);
 $lxc_module->mock('freeze', \&mocked_freeze);
 $lxc_module->mock('thaw', \&mocked_freeze); # re-use, as for now we don't care
 
-my $lxc_config_module = Test::MockModule('PVE::LXC::Config')->new();
+my $lxc_config_module = Test::MockModule->new('PVE::LXC::Config');
 $lxc_config_module->mock('config_file_lock', sub { return "snapshot-working/pve-test.lock"; });
 $lxc_config_module->mock('cfs_config_path', \&mocked_cfs_config_path);
 $lxc_config_module->mock('load_config', \&mocked_load_config);
 $lxc_config_module->mock('write_config', \&mocked_write_config);
 $lxc_config_module->mock('has_feature', \&mocked_has_feature);
 
-my $pve_cluster_module = Test::MockModule('PVE::Cluster')->new();
+my $pve_cluster_module = Test::MockModule->new('PVE::Cluster');
 sub mocked_get_config {
     my ($path) = @_;
     return PVE::Tools::file_get_contents("snapshot-working/$path");
@@ -319,7 +319,7 @@ sub mocked_get_config {
 $pve_cluster_module->mock('get_config', \&mocked_get_config);
 
 # ignore existing replication config
-my $repl_config_module = Test::MockModule('PVE::ReplicationConfig')->new();
+my $repl_config_module = Test::MockModule->new('PVE::ReplicationConfig');
 $repl_config_module->mock('check_for_existing_jobs' => sub { return undef });
 
 $running = 1;
@@ -399,7 +399,7 @@ $vol_snapshot_rollback_possible->{"local:snapshotable-disk-4"} = 1;
 
 printf("\n");
 printf("Setting up Mocking for PVE::Storage\n");
-my $storage_module = Test::MockModule('PVE::Storage')->new();
+my $storage_module = Test::MockModule->new('PVE::Storage');
 $storage_module->mock('activate_storage', \&mocked_activate_storage);
 $storage_module->mock('config', sub { return undef; });
 $storage_module->mock('volume_snapshot', \&mocked_volume_snapshot);
@@ -411,7 +411,7 @@ printf("\tconfig(), volume_snapshot(), volume_snapshot_delete(), volume_snapshot
 
 printf("\n");
 printf("Setting up Mocking for PVE::Tools\n");
-my $tools_module = Test::MockModule('PVE::Tools')->new();
+my $tools_module = Test::MockModule->new('PVE::Tools');
 $tools_module->mock('run_command' => \&mocked_run_command);
 printf("\trun_command() mocked\n");
 
-- 
2.30.2






More information about the pve-devel mailing list