build('d2d', 'test', $first, $third); $teendok = File::get($package['path'].'/_TEENDOK.md'); expect($teendok)->toContain('docker service update --force d2d-environment_queue') ->and($teendok)->toContain('docker service update --force d2d-environment_scheduler') // A 0 replikás scheduler miatt tudni kell, hogy a restart üresjárat lehet. ->and($teendok)->toContain('0 replikán fut'); // A restartnak a cache ürítés UTÁN kell jönnie: a frissen induló worker különben // a régi, cache-elt konfigot töltené be. expect(strpos($teendok, 'docker service update'))->toBeGreaterThan(strpos($teendok, 'config:clear')); deploymentCleanup($repository['path']); }); test('a queue worker nélküli környezetnél is kiderül, mit kell majd újraindítani', function () { deploymentAllowEnvironment(); $repository = deploymentTestRepository(); [$first, , $third] = $repository['commits']; $package = app(DeploymentPackageBuilder::class)->build('e2e', 'main', $first, $third); $teendok = File::get($package['path'].'/_TEENDOK.md'); expect($teendok)->toContain('docker service update --force t2t_scheduler') ->and($teendok)->toContain('t2t_queue'); deploymentCleanup($repository['path']); }); test('a teendők között szerepel a seeder futtatása a konkrét osztálynévvel', function () { deploymentAllowEnvironment(); $repository = deploymentTestRepository(); [$first, , $third] = $repository['commits']; $package = app(DeploymentPackageBuilder::class)->build('e2e', 'main', $first, $third); $teendok = File::get($package['path'].'/_TEENDOK.md'); expect($teendok)->toContain('php artisan db:seed --class=TesztSeeder') // A seeder puszta felmásolása nem futtatja le - ezt ki kell mondani. ->and($teendok)->toContain('NEM futtatja le') // A Pennant purge feltételes: Eloquent mentésnél a FeatureFlagObserver elvégzi. ->and($teendok)->toContain('pennant:purge') ->and($teendok)->toContain('cache:clear'); deploymentCleanup($repository['path']); }); test('a csomag a commitolt tartalmat viszi, nem a working tree állapotát', function () { deploymentAllowEnvironment(); $repository = deploymentTestRepository(); [$first, , $third] = $repository['commits']; // A working tree szándékos elrontása a commit után: ez nem kerülhet a csomagba. File::put($repository['path'].'/app/Árlista.php', "build('e2e', 'main', $first, $third); expect(File::get($package['path'].'/app/Árlista.php'))->not->toContain('NEM KERÜLHET') // A .gitattributes eol=lf miatt a git archive LF-fel ír, Windowson is. ->and(File::get($package['path'].'/app/Árlista.php'))->not->toContain("\r\n"); deploymentCleanup($repository['path']); }); test('a csomagból kimarad a kizárt és a kézzel kivett fájl, a törlendők külön listára kerülnek', function () { deploymentAllowEnvironment(); $repository = deploymentTestRepository(); [$first, , $third] = $repository['commits']; $package = app(DeploymentPackageBuilder::class)->build('e2e', 'main', $first, $third, ['app/Elso.php']); expect(File::exists($package['path'].'/app/Atnevezett.php'))->toBeTrue() ->and(File::exists($package['path'].'/app/Elso.php'))->toBeFalse() ->and(File::exists($package['path'].'/.env'))->toBeFalse() ->and(File::exists($package['path'].'/app/Regi.php'))->toBeFalse() ->and($package['counts']['skipped'])->toBe(1) ->and($package['counts']['missing'])->toBe(0); $torlendo = File::get($package['path'].'/_TORLENDO.txt'); expect($torlendo)->toContain('app/Regi.php') ->and($torlendo)->toContain('app/Atnevezendo.php'); deploymentCleanup($repository['path']); }); test('a csomag rögzíti a kirakott verziót', function () { deploymentAllowEnvironment(); $repository = deploymentTestRepository(); [$first, , $third] = $repository['commits']; $package = app(DeploymentPackageBuilder::class)->build('e2e', 'main', $first, $third); $version = json_decode(File::get($package['path'].'/public/deploy-version.json'), true); expect($version['commit'])->toBe($third) ->and($version['target'])->toBe('e2e') ->and($version['branch'])->toBe('main'); deploymentCleanup($repository['path']); }); test('a limit fölötti fájlszámnál nem készül csomag', function () { deploymentAllowEnvironment(); $repository = deploymentTestRepository(); [$first, , $third] = $repository['commits']; Config::set('deployment.max_files', 1); expect(fn () => app(DeploymentPackageBuilder::class)->build('e2e', 'main', $first, $third)) ->toThrow(RuntimeException::class); expect(File::exists(config('deployment.output_path')))->toBeFalse(); deploymentCleanup($repository['path']); }); test('a csomagoló szerveren akkor sem indul el, ha közvetlenül hívják', function () { deploymentAllowEnvironment(); $repository = deploymentTestRepository(); [$first, , $third] = $repository['commits']; Config::set('app.stage', 'PROD'); expect(fn () => app(DeploymentPackageBuilder::class)->build('e2e', 'main', $first, $third)) ->toThrow(RuntimeException::class); deploymentCleanup($repository['path']); }); test('a törlő szkript dry runban fut és ellenőrzi az app gyökeret', function () { deploymentAllowEnvironment(); $repository = deploymentTestRepository(); [$first, , $third] = $repository['commits']; $package = app(DeploymentPackageBuilder::class)->build('e2e', 'main', $first, $third); $script = File::get($package['path'].'/_torles.sh'); expect($script)->toStartWith('#!/usr/bin/env bash') ->and($script)->toContain('[[ -f artisan && -d app ]]') ->and($script)->toContain('"app/Regi.php"') // Windowson generáljuk, Linuxon fut: CRLF-fel a shebang sor törne el. ->and($script)->not->toContain("\r\n"); deploymentCleanup($repository['path']); });