2026-05-26 09:41:04 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
|
|
2026-05-26 09:51:38 +00:00
|
|
|
function createSyncBunnyFailingBinary(string $binDir, string $name): void
|
2026-05-26 09:41:04 +00:00
|
|
|
{
|
2026-05-26 09:51:38 +00:00
|
|
|
file_put_contents("{$binDir}/{$name}", <<<'SH'
|
|
|
|
|
#!/bin/sh
|
|
|
|
|
printf '%s %s\n' "$(basename "$0")" "$*" >> "$SYNC_BUNNY_TEST_LOG"
|
|
|
|
|
exit 1
|
|
|
|
|
SH);
|
2026-05-26 09:41:04 +00:00
|
|
|
chmod("{$binDir}/{$name}", 0755);
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-26 09:51:38 +00:00
|
|
|
it('syncs nightly versions to BunnyCDN without creating a GitHub PR', function () {
|
2026-05-26 09:41:04 +00:00
|
|
|
Http::fake([
|
2026-05-26 09:51:38 +00:00
|
|
|
'storage.bunnycdn.com/*' => Http::response([], 201),
|
|
|
|
|
'api.bunny.net/purge*' => Http::response([], 200),
|
2026-05-26 09:41:04 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$binDir = sys_get_temp_dir().'/sync-bunny-bin-'.uniqid();
|
|
|
|
|
$logFile = sys_get_temp_dir().'/sync-bunny-'.uniqid().'.log';
|
|
|
|
|
|
|
|
|
|
mkdir($binDir, 0755, true);
|
2026-05-26 09:51:38 +00:00
|
|
|
createSyncBunnyFailingBinary($binDir, 'gh');
|
|
|
|
|
createSyncBunnyFailingBinary($binDir, 'git');
|
2026-05-26 09:41:04 +00:00
|
|
|
|
|
|
|
|
$originalPath = getenv('PATH') ?: '';
|
|
|
|
|
putenv("PATH={$binDir}:{$originalPath}");
|
|
|
|
|
putenv("SYNC_BUNNY_TEST_LOG={$logFile}");
|
|
|
|
|
|
|
|
|
|
try {
|
2026-05-26 09:51:38 +00:00
|
|
|
$this->artisan('sync:bunny --release --nightly')
|
|
|
|
|
->expectsConfirmation('Are you sure you want to proceed?', 'yes')
|
|
|
|
|
->expectsOutputToContain('BunnyCDN sync: ✓ Complete')
|
|
|
|
|
->doesntExpectOutputToContain('GitHub PR')
|
2026-05-26 09:41:04 +00:00
|
|
|
->assertExitCode(0);
|
|
|
|
|
} finally {
|
|
|
|
|
putenv("PATH={$originalPath}");
|
|
|
|
|
putenv('SYNC_BUNNY_TEST_LOG');
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-26 09:51:38 +00:00
|
|
|
expect(file_exists($logFile))->toBeFalse();
|
2026-05-26 09:41:04 +00:00
|
|
|
|
2026-05-26 09:51:38 +00:00
|
|
|
Http::assertSent(fn ($request) => $request->url() === 'https://storage.bunnycdn.com/coolcdn/coolify-nightly/versions.json');
|
|
|
|
|
Http::assertSent(fn ($request) => str_starts_with($request->url(), 'https://api.bunny.net/purge')
|
|
|
|
|
&& $request['url'] === 'https://cdn.coollabs.io/coolify-nightly/versions.json');
|
|
|
|
|
});
|