buli
2022-04-15 900c50a247705d6fe8833e84d31b5d51616b7c26
force-app/main/default/classes/LogAutoSendScheduleTest.cls
@@ -1,21 +1,13 @@
@isTest
private class LogAutoSendScheduleTest {
    static testMethod void testExecute() {
        // This test runs a scheduled job at midnight Sept. 3rd. 2022
        String CRON_EXP = '0 0 0 3 9 ? 2022';
        System.Test.startTest();
        // Schedule the test job
        String jobId = system.schedule('LogAutoSendScheduleTest', CRON_EXP, new LogAutoSendSchedule());
        // Get the information from the CronTrigger API object
        CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE id = :jobId];
        // Verify the expressions are the same
        System.assertEquals(CRON_EXP, ct.CronExpression);
        // Verify the job has not run
        System.assertEquals(0, ct.TimesTriggered);
   @isTest static void test_assignOneMinute() {
      Datetime addOneM = System.now().addMinutes(2);
      String CRON_EXP = '0 ' + addOneM.minute() + ' ' + addOneM.hour() + ' ' + addOneM.day() + ' ' + addOneM.month() + ' ? ' + addOneM.year();
        LogAutoSendSchedule.assignOneMinute();
      CronTrigger oldcron = [select Id, CronJobDetail.Name from CronTrigger where CronExpression = :CRON_EXP and CronJobDetail.Name like 'LogAutoSendSBG%'];
        // Verify the next time the job will run
        System.assertEquals('2022-09-03 00:00:00', String.valueOf(ct.NextFireTime));
        System.Test.StopTest();
    }
        System.assertEquals('LogAutoSendSBG' + CRON_EXP, oldcron.CronJobDetail.Name);
   }
}