Files
AndyTranscribe/tests/Feature/DiskSpaceTest.php
T
ben 352b564f3a Add DiskSpaceService and DiskSpaceBar component for monitoring disk usage
Implement DiskSpaceService to provide snapshots of disk space usage, including total, free, and used bytes, as well as human-readable formats. Create DiskSpaceBar component to display disk usage information in the UI, including a progress bar that visually represents used space. Update app layout to include the DiskSpaceBar and add tests to ensure functionality of the disk space service and its integration in the layout.
2026-08-12 16:33:57 +02:00

51 lines
1.4 KiB
PHP

<?php
namespace Tests\Feature;
use App\Services\DiskSpaceService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Storage;
use Tests\TestCase;
class DiskSpaceTest extends TestCase
{
use RefreshDatabase;
public function test_disk_space_service_returns_snapshot_for_storage_path(): void
{
Cache::flush();
$snapshot = app(DiskSpaceService::class)->snapshot();
$this->assertNotNull($snapshot);
$this->assertGreaterThan(0, $snapshot['total_bytes']);
$this->assertGreaterThanOrEqual(0, $snapshot['free_bytes']);
$this->assertGreaterThanOrEqual(0, $snapshot['used_percent']);
$this->assertLessThanOrEqual(100, $snapshot['used_percent']);
$this->assertNotEmpty($snapshot['free_human']);
$this->assertNotEmpty($snapshot['total_human']);
}
public function test_disk_space_service_returns_null_for_missing_path(): void
{
Cache::flush();
$snapshot = app(DiskSpaceService::class)->snapshot('/path/that/does/not/exist-'.uniqid());
$this->assertNull($snapshot);
}
public function test_layout_shows_disk_space_bar(): void
{
Cache::flush();
Storage::fake('local');
$this->get(route('recordings.index'))
->assertOk()
->assertSee('Disk space')
->assertSee('free')
->assertSee('role="progressbar"', false);
}
}