$deployedVersion, 'commit' => 'deadbeef', 'source' => 'refs/tags/v'.$deployedVersion, ])); if ($ceiling !== null) { File::put($root.'/storage/app/deploy/release-ceiling', $ceiling); } $tagCommands = ''; foreach ($tags as $tag) { $tagCommands .= "git tag {$tag}\n"; } $result = Process::path($root)->timeout(90)->run(<< "\$stub/git" <<'GIT' #!/bin/sh if [ "\$1" = "fetch" ]; then exit 0; fi exec /usr/bin/git "\$@" GIT chmod +x "\$stub/git" printf '#!/bin/sh\nexit 1\n' > "\$stub/docker" chmod +x "\$stub/docker" PATH="\$stub:\$PATH" bash deploy/update-agent.sh >/dev/null 2>&1 || true rm -rf "\$stub" BASH); expect($result->successful())->toBeTrue($result->errorOutput()); $status = json_decode(File::get($root.'/storage/app/deploy/update-status.json'), true); File::deleteDirectory($root); return $status; } it('offers only up to the ceiling', function () { // Ausgeliefert 1.7.3, vorhanden bis v9.9.9, Decke auf v9.9.8: genau eine // Aktualisierung, und das Ziel ist die Decke. $status = runAgentWithCeiling('v9.9.8', ['v9.9.8', 'v9.9.9']); expect($status['target_release'])->toBe('v9.9.8') ->and($status['behind'])->toBe(1) ->and($status['ceiling'])->toBe('v9.9.8') ->and($status['ceiling_error'])->toBe(''); }); it('offers nothing when the ceiling points at a tag that does not exist', function () { // Die Decke faellt ZU. Ein Rueckfall auf "neueste" installierte genau das, // wovon der Besitzer weggenagelt hat. $status = runAgentWithCeiling('v9.9.7', ['v9.9.8', 'v9.9.9']); expect($status['behind'])->toBe(0) ->and($status['ceiling_error'])->toBe('ceiling_missing') ->and($status['target_release'])->toBe(''); }); it('offers nothing when the ceiling is malformed', function () { $status = runAgentWithCeiling('neueste bitte', ['v9.9.8', 'v9.9.9']); expect($status['behind'])->toBe(0) ->and($status['ceiling_error'])->toBe('ceiling_invalid'); }); it('behaves exactly as before without a ceiling', function () { $status = runAgentWithCeiling(null, ['v9.9.8', 'v9.9.9']); expect($status['target_release'])->toBe('v9.9.9') ->and($status['ceiling'])->toBe('') ->and($status['ceiling_error'])->toBe(''); }); it('reports the versions that may be pinned to', function () { $status = runAgentWithCeiling(null, ['v9.9.8', 'v9.9.9']); expect($status['releases'])->toContain('v9.9.9') ->and($status['releases'])->toContain('v9.9.8'); });