mivita/tests/Unit/Monitoring/ReleaseTest.php
Kevin e1c6178bc7 Git-Deploy per Tag: deploy.sh, Version aus RELEASE, Worker-Pruefung
- dev/betrieb/deploy.sh: Tag auschecken, composer, Caches leeren (bewusst
  kein route:/config:cache wegen hostabhaengiger Routen und env()-Aufrufen),
  horizon:terminate, FPM-Reload, Worker-Pruefung am Ende
- dev/betrieb/README.md: Einrichtung Server, Umstellung des Live-Verzeichnisses,
  Release, Deploy, Rollback
- config('app.version') aus RELEASE, php artisan about --only=mivita
- monitoring:queue-probe prueft nach dem Deploy, ob Horizon Jobs abholt
- Vorlage dev/git-deploy-monitoring aus Pressekonto

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 10:11:34 +00:00

38 lines
1.1 KiB
PHP

<?php
use App\Support\Monitoring\Release;
/**
* Versionskennung: APP_VERSION vor der Datei RELEASE, die
* dev/betrieb/deploy.sh beim Deploy mit dem Tag beschreibt.
*/
beforeEach(function () {
$this->dir = sys_get_temp_dir().'/release-test-'.uniqid();
mkdir($this->dir);
});
afterEach(function () {
@unlink($this->dir.'/RELEASE');
@rmdir($this->dir);
});
test('the configured value wins over the release file', function () {
file_put_contents($this->dir.'/RELEASE', "v1.0.0\n");
expect(Release::current('v1.2.0', $this->dir))->toBe('v1.2.0');
});
test('the release file is used when nothing is configured', function () {
file_put_contents($this->dir.'/RELEASE', "v1.3.1\n");
expect(Release::current(null, $this->dir))->toBe('v1.3.1')
->and(Release::current(' ', $this->dir))->toBe('v1.3.1');
});
test('without file or with garbage there is no release', function () {
expect(Release::current(null, $this->dir))->toBeNull();
file_put_contents($this->dir.'/RELEASE', '<git rev-parse --short HEAD> # bei jedem Deploy');
expect(Release::current(null, $this->dir))->toBeNull();
});