mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-13 23:18:10 +00:00
feat(#17): add commands and jobs to poll, download and update firmware
feat(#17): add commands and jobs to poll, download and update firmware feat(#17): update firmware modal feat(#17): add tests
This commit is contained in:
parent
93aac51182
commit
87b9b57c3d
13 changed files with 567 additions and 3 deletions
38
tests/Feature/Jobs/FirmwareDownloadJobTest.php
Normal file
38
tests/Feature/Jobs/FirmwareDownloadJobTest.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
use App\Jobs\FirmwareDownloadJob;
|
||||
use App\Models\Firmware;
|
||||
use Illuminate\Http\Client\ConnectionException;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
beforeEach(function () {
|
||||
Storage::fake('public');
|
||||
Storage::disk('public')->makeDirectory('/firmwares');
|
||||
});
|
||||
|
||||
test('it creates firmwares directory if it does not exist', function () {
|
||||
$firmware = Firmware::factory()->create([
|
||||
'url' => 'https://example.com/firmware.bin',
|
||||
'version_tag' => '1.0.0',
|
||||
]);
|
||||
|
||||
(new FirmwareDownloadJob($firmware))->handle();
|
||||
|
||||
expect(Storage::disk('public')->exists('firmwares'))->toBeTrue();
|
||||
});
|
||||
|
||||
test('it downloads firmware and updates storage location', function () {
|
||||
Http::fake([
|
||||
'https://example.com/firmware.bin' => Http::response('fake firmware content', 200),
|
||||
]);
|
||||
|
||||
$firmware = Firmware::factory()->create([
|
||||
'url' => 'https://example.com/firmware.bin',
|
||||
'version_tag' => '1.0.0',
|
||||
]);
|
||||
|
||||
(new FirmwareDownloadJob($firmware))->handle();
|
||||
|
||||
expect($firmware->fresh()->storage_location)->toBe('firmwares/FW1.0.0.bin');
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue