[pve-devel] [PATCH qemu-server v2 16/49] test: collect mocked functions for QemuServer module
Fiona Ebner
f.ebner at proxmox.com
Tue Jul 1 17:40:36 CEST 2025
Also order them alphabetically.
Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---
src/test/MigrationTest/QmMock.pm | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)
diff --git a/src/test/MigrationTest/QmMock.pm b/src/test/MigrationTest/QmMock.pm
index 3eaa131f..de7f4cd7 100644
--- a/src/test/MigrationTest/QmMock.pm
+++ b/src/test/MigrationTest/QmMock.pm
@@ -50,21 +50,6 @@ $inotify_module->mock(
},
);
-$MigrationTest::Shared::qemu_server_module->mock(
- nodename => sub {
- return $nodename;
- },
- config_to_command => sub {
- return ['mocked_kvm_command'];
- },
- vm_start_nolock => sub {
- my ($storecfg, $vmid, $conf, $params, $migrate_opts) = @_;
- $forcemachine = $params->{forcemachine}
- or die "mocked vm_start_nolock - expected 'forcemachine' parameter\n";
- $MigrationTest::Shared::qemu_server_module->original('vm_start_nolock')->(@_);
- },
-);
-
my $qemu_server_helpers_module = Test::MockModule->new("PVE::QemuServer::Helpers");
$qemu_server_helpers_module->mock(
vm_running_locally => sub {
@@ -113,6 +98,9 @@ $MigrationTest::Shared::storage_module->mock(
);
$MigrationTest::Shared::qemu_server_module->mock(
+ config_to_command => sub {
+ return ['mocked_kvm_command'];
+ },
mon_cmd => sub {
my ($vmid, $command, %params) = @_;
@@ -127,6 +115,9 @@ $MigrationTest::Shared::qemu_server_module->mock(
}
die "mon_cmd (mocked) - implement me: $command";
},
+ nodename => sub {
+ return $nodename;
+ },
run_command => sub {
my ($cmd_full, %param) = @_;
@@ -149,6 +140,12 @@ $MigrationTest::Shared::qemu_server_module->mock(
file_set_contents("${RUN_DIR_PATH}/nbd_info", to_json($nbd));
return $nbd;
},
+ vm_start_nolock => sub {
+ my ($storecfg, $vmid, $conf, $params, $migrate_opts) = @_;
+ $forcemachine = $params->{forcemachine}
+ or die "mocked vm_start_nolock - expected 'forcemachine' parameter\n";
+ $MigrationTest::Shared::qemu_server_module->original('vm_start_nolock')->(@_);
+ },
);
our $cmddef = {
--
2.47.2
More information about the pve-devel
mailing list