mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-07-27 05:52:32 +00:00
fix mocking in notification tests
PVE::Notify::send_notification is now private (the mocking was for the old api) 'cfs_read_file' gets exported into PVE::Notify before it gets mocked, so it needs to be mocked inside PVE::Notify, not PVE::Cluster. Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
e5721b9062
commit
3571d98b5f
@ -37,15 +37,25 @@ my $result_text;
|
|||||||
my $result_properties;
|
my $result_properties;
|
||||||
|
|
||||||
my $mock_notification_module = Test::MockModule->new('PVE::Notify');
|
my $mock_notification_module = Test::MockModule->new('PVE::Notify');
|
||||||
$mock_notification_module->mock('send_notification', sub {
|
my $mocked_notify = sub {
|
||||||
my ($channel, $severity, $title, $text, $properties) = @_;
|
my ($channel, $severity, $title, $text, $properties) = @_;
|
||||||
|
|
||||||
$result_text = $text;
|
$result_text = $text;
|
||||||
$result_properties = $properties;
|
$result_properties = $properties;
|
||||||
});
|
};
|
||||||
|
my $mocked_notify_short = sub {
|
||||||
|
my ($channel, @rest) = @_;
|
||||||
|
return $mocked_notify->($channel, '<some severity>', @rest);
|
||||||
|
};
|
||||||
|
|
||||||
my $mock_cluster_module = Test::MockModule->new('PVE::Cluster');
|
$mock_notification_module->mock(
|
||||||
$mock_cluster_module->mock('cfs_read_file', sub {
|
'notify' => $mocked_notify,
|
||||||
|
'info' => $mocked_notify_short,
|
||||||
|
'notice' => $mocked_notify_short,
|
||||||
|
'warning' => $mocked_notify_short,
|
||||||
|
'error' => $mocked_notify_short,
|
||||||
|
);
|
||||||
|
$mock_notification_module->mock('cfs_read_file', sub {
|
||||||
my $path = shift;
|
my $path = shift;
|
||||||
|
|
||||||
if ($path eq 'datacenter.cfg') {
|
if ($path eq 'datacenter.cfg') {
|
||||||
|
Loading…
Reference in New Issue
Block a user