#!/usr/local/cpanel/3rdparty/bin/perl -w
# cpanel - plugins/cpanel/koality/perl/usr/local/cpanel/t/medium/Cpanel-Admin-Modules-Cpanel-site_quality_monitoring.t
#                                                  Copyright 2023 cPanel, L.L.C.
#                                                           All rights reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited

use cPstrict;

use Test2::V0;
use Test2::Tools::Explain;
use Test2::Plugin::NoWarnings;
use Test2::Tools::Subtest;
use Test2::Tools::Exception;

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

use Test::Cpanel::Policy testing => 'Cpanel::Admin::Modules::Cpanel::site_quality_monitoring';

use Cpanel::Admin::Modules::Cpanel::site_quality_monitoring;

my $server_uuid    = '4242424242424242424242424242424242424242424242424242424242424242';

subtest 'GET_SERVER_UUID' => sub {

    my $mock_uuid_file = Test::MockFile->file( Cpanel::Admin::Modules::Cpanel::site_quality_monitoring::UUID_FILE(), $server_uuid );
    is( Cpanel::Admin::Modules::Cpanel::site_quality_monitoring::GET_SERVER_UUID(), $server_uuid, "Got the expected cpanel uuid" );

    # Test::MockFile requires the previous mock to be undone before it can be re-mocked
    $mock_uuid_file = undef;
    $mock_uuid_file = Test::MockFile->file( Cpanel::Admin::Modules::Cpanel::site_quality_monitoring::UUID_FILE() );
    is( Cpanel::Admin::Modules::Cpanel::site_quality_monitoring::GET_SERVER_UUID(), '', "Empty string returned when the UUID file does not exist." );
};

done_testing;
