Add SealShare file sharing application with encryption, branding, auth, Docker, and Octane support
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
4790be8142
commit
e37b322dde
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Share;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
test('cleanup removes expired shares', function () {
|
||||
Storage::fake('shares');
|
||||
|
||||
$expired = Share::factory()->expired()->create();
|
||||
$active = Share::factory()->expiresInHours(24)->create();
|
||||
$noExpiry = Share::factory()->create(['expires_at' => null]);
|
||||
|
||||
$this->artisan('shares:cleanup')
|
||||
->expectsOutputToContain('Cleaned up 1 expired share(s)')
|
||||
->assertExitCode(0);
|
||||
|
||||
expect(Share::query()->find($expired->id))->toBeNull();
|
||||
expect(Share::query()->find($active->id))->not->toBeNull();
|
||||
expect(Share::query()->find($noExpiry->id))->not->toBeNull();
|
||||
});
|
||||
|
||||
test('cleanup removes shares that reached download limit', function () {
|
||||
Storage::fake('shares');
|
||||
|
||||
$reachedLimit = Share::factory()->withMaxDownloads(5)->create(['download_count' => 5]);
|
||||
$underLimit = Share::factory()->withMaxDownloads(5)->create(['download_count' => 3]);
|
||||
|
||||
$this->artisan('shares:cleanup')
|
||||
->expectsOutputToContain('Cleaned up 1 expired share(s)')
|
||||
->assertExitCode(0);
|
||||
|
||||
expect(Share::query()->find($reachedLimit->id))->toBeNull();
|
||||
expect(Share::query()->find($underLimit->id))->not->toBeNull();
|
||||
});
|
||||
|
||||
test('cleanup handles no expired shares', function () {
|
||||
Storage::fake('shares');
|
||||
|
||||
Share::factory()->create(['expires_at' => null]);
|
||||
|
||||
$this->artisan('shares:cleanup')
|
||||
->expectsOutputToContain('Cleaned up 0 expired share(s)')
|
||||
->assertExitCode(0);
|
||||
});
|
||||
|
||||
test('cleanup removes both expired and download-limited shares', function () {
|
||||
Storage::fake('shares');
|
||||
|
||||
$expired = Share::factory()->expired()->create();
|
||||
$limitReached = Share::factory()->withMaxDownloads(1)->create(['download_count' => 1]);
|
||||
$active = Share::factory()->create(['expires_at' => null]);
|
||||
|
||||
$this->artisan('shares:cleanup')
|
||||
->expectsOutputToContain('Cleaned up 2 expired share(s)')
|
||||
->assertExitCode(0);
|
||||
|
||||
expect(Share::query()->find($expired->id))->toBeNull();
|
||||
expect(Share::query()->find($limitReached->id))->toBeNull();
|
||||
expect(Share::query()->find($active->id))->not->toBeNull();
|
||||
});
|
||||
Reference in New Issue
Block a user