51 lines
1.7 KiB
PHP
51 lines
1.7 KiB
PHP
<?php
|
|
|
|
use App\Models\Setting;
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
it('version bump fails when no version', function (): void {
|
|
Setting::where('key', 'version')->delete();
|
|
$exitCode = \Illuminate\Support\Facades\Artisan::call('version:bump');
|
|
expect($exitCode)->toBe(1);
|
|
});
|
|
|
|
it('version bump fails when invalid version', function (): void {
|
|
Setting::updateOrCreate(['key' => 'version'], ['value' => 'bad']);
|
|
$exitCode = \Illuminate\Support\Facades\Artisan::call('version:bump');
|
|
expect($exitCode)->toBe(1);
|
|
});
|
|
|
|
it('version set fails when invalid version', function (): void {
|
|
$exitCode = \Illuminate\Support\Facades\Artisan::call('version:set', ['version' => 'bad']);
|
|
expect($exitCode)->toBe(1);
|
|
});
|
|
|
|
it('version fetch fails when no version', function (): void {
|
|
Setting::where('key', 'version')->delete();
|
|
$exitCode = \Illuminate\Support\Facades\Artisan::call('version:fetch');
|
|
expect($exitCode)->toBe(1);
|
|
});
|
|
|
|
it('version release fails when missing config', function (): void {
|
|
Setting::updateOrCreate(['key' => 'version'], ['value' => '1.2.3']);
|
|
putenv('GITEA_TOKEN');
|
|
putenv('GITEA_OWNER');
|
|
putenv('GITEA_REPO');
|
|
$exitCode = \Illuminate\Support\Facades\Artisan::call('version:release');
|
|
expect($exitCode)->toBe(1);
|
|
});
|
|
|
|
it('version release handles create failure', function (): void {
|
|
Setting::updateOrCreate(['key' => 'version'], ['value' => '1.2.3']);
|
|
putenv('GITEA_TOKEN=token');
|
|
putenv('GITEA_OWNER=owner');
|
|
putenv('GITEA_REPO=repo');
|
|
|
|
Http::fake([
|
|
'*' => Http::response([], 500),
|
|
]);
|
|
|
|
$exitCode = \Illuminate\Support\Facades\Artisan::call('version:release');
|
|
expect($exitCode)->toBe(1);
|
|
});
|