chore: run pint

This commit is contained in:
Benjamin Nussbaum 2025-06-03 18:18:25 +02:00
parent 78f1f74594
commit 4102d33336
11 changed files with 37 additions and 37 deletions

View file

@ -5,6 +5,7 @@ namespace Tests\Feature;
use App\Models\Device;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use function Pest\Laravel\actingAs;
uses(RefreshDatabase::class);

View file

@ -2,7 +2,6 @@
use App\Jobs\FirmwareDownloadJob;
use App\Models\Firmware;
use Illuminate\Http\Client\ConnectionException;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Storage;

View file

@ -13,11 +13,11 @@ test('it creates new firmware record when polling', function () {
Http::fake([
'usetrmnl.com/api/firmware/latest' => Http::response([
'version' => '1.0.0',
'url' => 'https://example.com/firmware.bin'
], 200)
'url' => 'https://example.com/firmware.bin',
], 200),
]);
(new FirmwarePollJob())->handle();
(new FirmwarePollJob)->handle();
expect(Firmware::where('version_tag', '1.0.0')->exists())->toBeTrue()
->and(Firmware::where('version_tag', '1.0.0')->first())
@ -29,17 +29,17 @@ test('it updates existing firmware record when polling', function () {
$existingFirmware = Firmware::factory()->create([
'version_tag' => '1.0.0',
'url' => 'https://old-url.com/firmware.bin',
'latest' => true
'latest' => true,
]);
Http::fake([
'usetrmnl.com/api/firmware/latest' => Http::response([
'version' => '1.0.0',
'url' => 'https://new-url.com/firmware.bin'
], 200)
'url' => 'https://new-url.com/firmware.bin',
], 200),
]);
(new FirmwarePollJob())->handle();
(new FirmwarePollJob)->handle();
expect($existingFirmware->fresh())
->url->toBe('https://new-url.com/firmware.bin')
@ -49,17 +49,17 @@ test('it updates existing firmware record when polling', function () {
test('it marks previous firmware as not latest when new version is found', function () {
$oldFirmware = Firmware::factory()->create([
'version_tag' => '1.0.0',
'latest' => true
'latest' => true,
]);
Http::fake([
'usetrmnl.com/api/firmware/latest' => Http::response([
'version' => '1.1.0',
'url' => 'https://example.com/firmware.bin'
], 200)
'url' => 'https://example.com/firmware.bin',
], 200),
]);
(new FirmwarePollJob())->handle();
(new FirmwarePollJob)->handle();
expect($oldFirmware->fresh()->latest)->toBeFalse()
->and(Firmware::where('version_tag', '1.1.0')->first()->latest)->toBeTrue();
@ -69,10 +69,10 @@ test('it handles connection exception gracefully', function () {
Http::fake([
'usetrmnl.com/api/firmware/latest' => function () {
throw new ConnectionException('Connection failed');
}
},
]);
(new FirmwarePollJob())->handle();
(new FirmwarePollJob)->handle();
// Verify no firmware records were created
expect(Firmware::count())->toBe(0);
@ -80,10 +80,10 @@ test('it handles connection exception gracefully', function () {
test('it handles invalid response gracefully', function () {
Http::fake([
'usetrmnl.com/api/firmware/latest' => Http::response(null, 200)
'usetrmnl.com/api/firmware/latest' => Http::response(null, 200),
]);
(new FirmwarePollJob())->handle();
(new FirmwarePollJob)->handle();
// Verify no firmware records were created
expect(Firmware::count())->toBe(0);
@ -92,11 +92,11 @@ test('it handles invalid response gracefully', function () {
test('it handles missing version in response gracefully', function () {
Http::fake([
'usetrmnl.com/api/firmware/latest' => Http::response([
'url' => 'https://example.com/firmware.bin'
], 200)
'url' => 'https://example.com/firmware.bin',
], 200),
]);
(new FirmwarePollJob())->handle();
(new FirmwarePollJob)->handle();
// Verify no firmware records were created
expect(Firmware::count())->toBe(0);
@ -105,11 +105,11 @@ test('it handles missing version in response gracefully', function () {
test('it handles missing url in response gracefully', function () {
Http::fake([
'usetrmnl.com/api/firmware/latest' => Http::response([
'version' => '1.0.0'
], 200)
'version' => '1.0.0',
], 200),
]);
(new FirmwarePollJob())->handle();
(new FirmwarePollJob)->handle();
// Verify no firmware records were created
expect(Firmware::count())->toBe(0);

View file

@ -20,8 +20,8 @@ test('device log casts log_entry to array', function () {
'log_entry' => [
'message' => 'test message',
'level' => 'info',
'timestamp' => time()
]
'timestamp' => time(),
],
]);
expect($log->log_entry)->toBeArray()
@ -33,7 +33,7 @@ test('device log casts device_timestamp to datetime', function () {
Device::factory()->create();
$timestamp = now();
$log = DeviceLog::factory()->create([
'device_timestamp' => $timestamp
'device_timestamp' => $timestamp,
]);
expect($log->device_timestamp)->toBeInstanceOf(\Carbon\Carbon::class)
@ -56,8 +56,8 @@ test('device log can be created with minimal required fields', function () {
'device_id' => $device->id,
'device_timestamp' => now(),
'log_entry' => [
'message' => 'test message'
]
'message' => 'test message',
],
]);
expect($log->exists)->toBeTrue()