Added refresh-remote-state option to deploy command
Tests / PHP 8.3 (push) Canceled after 0s
Tests / PHP 8.4 (push) Canceled after 0s

This commit is contained in:
Meghdad committed 2026-06-25 15:26:28 +03:30
1 parent 99468ae0d2
commit 47d6df6bbe
4 files changed
+68 -2

No files matched your search

+42 -2
View File
@@ -177,6 +177,46 @@ test('ftp deploy dry run leaves remote files and state untouched', function () {
->and(Storage::disk('ftp_deploy')->get('storage/framework/testing/ftp-deploy-state.json'))->toBe($remoteState);
});
test('ftp deploy can refresh remote sync state through api before comparing files', function () {
ftpDeployWriteLocalFile($this->localRoot, 'same.txt', 'same contents');
Storage::disk('ftp_deploy')->put('same.txt', 'same contents');
Storage::disk('ftp_deploy')->put('storage/framework/testing/ftp-deploy-state.json', ftpDeploySyncState([]));
$refreshedState = ftpDeploySyncState([
'same.txt' => 'same contents',
], generatedTime: 123);
Http::fake(function () use ($refreshedState) {
Storage::disk('ftp_deploy')->put('storage/framework/testing/ftp-deploy-state.json', $refreshedState);
return Http::response([
'success' => true,
'path' => '/var/www/storage/app/.ftp-deploy-sync-state.json',
'files' => 1,
'folders' => 0,
'generated_time' => 123,
'state' => json_decode($refreshedState, true, flags: JSON_THROW_ON_ERROR),
]);
});
$this->artisan('ftp:deploy', [
'--refresh-remote-state' => true,
'--yes' => true,
])->assertExitCode(0);
$state = json_decode(
Storage::disk('ftp_deploy')->get('storage/framework/testing/ftp-deploy-state.json'),
true,
flags: JSON_THROW_ON_ERROR,
);
expect($state['generatedTime'])->toBe(123);
Http::assertSent(fn ($request): bool => $request->url() === 'https://example.test/ftp/generate-sync-state'
&& $request->hasHeader('Authorization', 'Bearer secret-token'));
});
test('ftp deploy force uploads every included file', function () {
ftpDeployWriteLocalFile($this->localRoot, 'same.txt', 'same contents');
ftpDeployWriteLocalFile($this->localRoot, 'other.txt', 'other contents');
@@ -208,12 +248,12 @@ function ftpDeployWriteLocalFile(string $root, string $path, string $contents):
/**
* @param array<string, string> $files
*/
function ftpDeploySyncState(array $files): string
function ftpDeploySyncState(array $files, int $generatedTime = 1): string
{
return json_encode([
'description' => 'test sync state',
'version' => '1.0.0',
'generatedTime' => 1,
'generatedTime' => $generatedTime,
'data' => collect($files)
->map(fn (string $contents, string $name): array => [
'type' => 'file',