add summary command
This commit is contained in:
6 files changed
+207
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
@@ -18,6 +19,8 @@ beforeEach(function (): void {
|
||||
'services.ftp_deploy.local_root' => $this->localRoot,
|
||||
'services.ftp_deploy.state_path' => 'storage/framework/testing/ftp-deploy-state.json',
|
||||
'services.ftp_deploy.api_token' => 'secret-token',
|
||||
'services.ftp_deploy.api_url' => 'https://example.test/ftp/generate-sync-state',
|
||||
'services.ftp_deploy.api_timeout' => 10,
|
||||
'services.ftp_deploy.exclude' => ['ignored', '*.tmp'],
|
||||
]);
|
||||
|
||||
@@ -33,12 +36,47 @@ test('package registers default config commands and route', function () {
|
||||
expect(config('filesystems.disks.ftp_deploy.driver'))->toBe('ftp')
|
||||
->and(config('services.ftp_deploy.disk'))->toBe('ftp_deploy')
|
||||
->and(Artisan::all())->toHaveKeys([
|
||||
'ftp:api-summary',
|
||||
'ftp:deploy',
|
||||
'ftp:generate-sync-state',
|
||||
])
|
||||
->and(Route::has('ftp-deploy.generate-sync-state'))->toBeTrue();
|
||||
});
|
||||
|
||||
test('api summary command calls configured api and prints the returned summary', function () {
|
||||
Http::fake([
|
||||
'https://example.test/ftp/generate-sync-state' => Http::response([
|
||||
'success' => true,
|
||||
'path' => '/var/www/storage/app/.ftp-deploy-sync-state.json',
|
||||
'files' => 12,
|
||||
'folders' => 4,
|
||||
'generated_time' => 1782361358583,
|
||||
'state' => [
|
||||
'generatedTime' => 1782361358583,
|
||||
'data' => [],
|
||||
],
|
||||
]),
|
||||
]);
|
||||
|
||||
$this->artisan('ftp:api-summary')
|
||||
->expectsOutputToContain('Files')
|
||||
->assertExitCode(0);
|
||||
|
||||
Http::assertSent(fn ($request): bool => $request->url() === 'https://example.test/ftp/generate-sync-state'
|
||||
&& $request->hasHeader('Authorization', 'Bearer secret-token'));
|
||||
});
|
||||
|
||||
test('api summary command fails when api returns an error status', function () {
|
||||
Http::fake([
|
||||
'https://example.test/ftp/generate-sync-state' => Http::response([
|
||||
'message' => 'Invalid FTP deploy API token.',
|
||||
], 403),
|
||||
]);
|
||||
|
||||
$this->artisan('ftp:api-summary')
|
||||
->assertExitCode(1);
|
||||
});
|
||||
|
||||
test('generate sync state command writes state and honors excludes', function () {
|
||||
ftpDeployWriteLocalFile($this->localRoot, 'keep.txt', 'keep contents');
|
||||
ftpDeployWriteLocalFile($this->localRoot, 'ignored/file.txt', 'ignored contents');
|
||||
|
||||
Reference in new issue
Block a user