feat(metrics): add pressure threshold helper

This commit is contained in:
Aditya Tripathi
2026-09-16 07:54:57 +00:00
parent dbcef807ae
commit f950f9058b
2 changed files with 61 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
<?php
use App\Support\Metrics\PressureLevel;
it('classifies cpu/memory pressure at 70/90 cutoffs', function () {
expect(PressureLevel::for(10, 'cpu'))->toBe('ok');
expect(PressureLevel::for(70, 'cpu'))->toBe('warning');
expect(PressureLevel::for(89.9, 'memory'))->toBe('warning');
expect(PressureLevel::for(90, 'memory'))->toBe('error');
});
it('classifies disk pressure at 80/90 cutoffs', function () {
expect(PressureLevel::for(75, 'disk'))->toBe('ok');
expect(PressureLevel::for(80, 'disk'))->toBe('warning');
expect(PressureLevel::for(95, 'disk'))->toBe('error');
});
it('treats a null percent as ok and maps levels to classes', function () {
expect(PressureLevel::for(null, 'cpu'))->toBe('ok');
expect(PressureLevel::textClass('error'))->toContain('text-red-500');
expect(PressureLevel::barClass('warning'))->toContain('bg-orange-500');
});