Skip to content

Commit

Permalink
Merge branch 'main' of github.com:spatie/laravel-health
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Nov 25, 2021
2 parents 44b53dd + da95325 commit dd4e98d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/Checks/Checks/ScheduleCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ public function run(): Result

$lastHeartbeatTimestamp = cache()->get($this->cacheKey);

if (!$lastHeartbeatTimestamp) {
if (! $lastHeartbeatTimestamp) {
return $result->failed('The schedule did not run yet.');
}

$latestHeartbeatAt = Carbon::createFromTimestamp($lastHeartbeatTimestamp);

$minutesAgo = $latestHeartbeatAt->diffInMinutes() +1;
$minutesAgo = $latestHeartbeatAt->diffInMinutes() + 1;

if ($minutesAgo > $this->heartbeatMaxAgeInMinutes) {
return $result->failed("The last run of the schedule was more than {$minutesAgo} minutes ago.");
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/ScheduleCheckHeartbeatCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function handle(): int
{
/** @var ScheduleCheck|null $scheduleCheck */
$scheduleCheck = Health::registeredChecks()->first(
fn(Check $check) => $check instanceof ScheduleCheck
fn (Check $check) => $check instanceof ScheduleCheck
);

if (! $scheduleCheck) {
Expand Down
10 changes: 5 additions & 5 deletions tests/Checks/ScheduleCheckTest.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<?php

use function Pest\Laravel\artisan;
use Spatie\Health\Checks\Checks\ScheduleCheck;
use Spatie\Health\Commands\ScheduleCheckHeartbeatCommand;
use Spatie\Health\Enums\Status;
use Spatie\Health\Facades\Health;
use function Pest\Laravel\artisan;
use function Spatie\PestPluginTestTime\testTime;

beforeEach(function() {
beforeEach(function () {
$this->scheduleCheck = ScheduleCheck::new();

Health::checks([
ScheduleCheck::new()
ScheduleCheck::new(),
]);

testTime()->freeze();
});

it('can check whether the scheduler is still running', function() {
it('can check whether the scheduler is still running', function () {
artisan(ScheduleCheckHeartbeatCommand::class)->assertSuccessful();

$result = $this->scheduleCheck->run();
Expand All @@ -32,7 +32,7 @@
expect($result->status)->toBe(Status::failed());
});

it('can use custom max age of the heartbeat', function() {
it('can use custom max age of the heartbeat', function () {
$this->scheduleCheck->heartbeatMaxAgeInMinutes(2);

artisan(ScheduleCheckHeartbeatCommand::class)->assertSuccessful();
Expand Down
2 changes: 1 addition & 1 deletion tests/Notifications/CheckFailedNotificationTest.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

use Illuminate\Support\Facades\Notification;
use Spatie\TestTime\TestTime;
use function Pest\Laravel\artisan;
use Spatie\Health\Commands\RunChecksCommand;
use Spatie\Health\Facades\Health;
use Spatie\Health\Notifications\CheckFailedNotification;
use Spatie\Health\Tests\TestClasses\FakeUsedDiskSpaceCheck;
use Spatie\TestTime\TestTime;

beforeEach(function () {
Notification::fake();
Expand Down

0 comments on commit dd4e98d

Please sign in to comment.