]> git.proxmox.com Git - pve-manager.git/commitdiff
test: fix mail_test for non-root user
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Thu, 13 Aug 2020 10:54:51 +0000 (12:54 +0200)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Thu, 13 Aug 2020 10:54:51 +0000 (12:54 +0200)
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
test/mail_test.pl

index 6c32f0fc12dc1b7217cab0385989151e8893283e..d011444190b70b497d1b59f58da7644aaed547df 100755 (executable)
@@ -35,13 +35,24 @@ sub prepare_long_mail {
 
 my ($result_text, $result_html);
 
-my $mock_module = Test::MockModule->new('PVE::Tools');
-$mock_module->mock('sendmail', sub {
+my $mock_tools_module = Test::MockModule->new('PVE::Tools');
+$mock_tools_module->mock('sendmail', sub {
     my (undef, undef, $text, $html, undef, undef) = @_;
     $result_text = $text;
     $result_html = $html;
 });
 
+my $mock_cluster_module = Test::MockModule->new('PVE::Cluster');
+$mock_cluster_module->mock('cfs_read_file', sub {
+    my $path = shift;
+
+    if ($path eq 'datacenter.cfg') {
+       return {};
+    } else {
+       die "unexpected cfs_read_file\n";
+    }
+});
+
 my $MAILTO = ['test_address@proxmox.com'];
 my $SELF = {
     opts => { mailto => $MAILTO },