#!/usr/local/cpanel/3rdparty/bin/perl -w

#                                      Copyright 2024 WebPros International, LLC
#                                                           All rights reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited.

package t::Cpanel::Config::ConfigObj::Driver::ServerMonitoring;

use cPstrict;

use Test::More tests => 7 + 1;    # +1NoWarnings  # +1logger

use Test::Cpanel::Policy;

use Test::NoWarnings;
use Test::MockModule qw/strict/;

use parent qw(
  Cpanel::TestObj
);

use Cpanel::Config::ConfigObj                           ();
use Cpanel::Config::ConfigObj::Driver::ServerMonitoring ();

my $set_up_mock = Test::MockModule->new('Whostmgr::360Monitoring::Setup');
$set_up_mock->redefine( 'local_enable'  => sub { return 1; } );
$set_up_mock->redefine( 'local_disable' => sub { return 1; } );
my $so  = Cpanel::Config::ConfigObj->new();
my $obj = Cpanel::Config::ConfigObj::Driver::ServerMonitoring->init($so);

isa_ok( $obj, 'Cpanel::Config::ConfigObj::Driver::ServerMonitoring' );
isa_ok( $obj, 'Cpanel::Config::ConfigObj::Interface::Config::v1' );
isa_ok( $obj, 'Cpanel::Config::ConfigObj::Interface::Whostmgr' );

ok( $obj->enable(),  "enable works as expected" );
ok( $obj->disable(), "disable works as expected" );
is( $obj->check(), 1, "check returns 1" );
like(
    $obj->info(),
    qr/now provides the Server Monitoring feature. You can use Server Monitoring to track your server’s performance and up-time statistics./,
    "info is correct"
);

1;
