Files
coolify/tests/Unit/BitbucketCheckoutCommitTest.php
033f0c84da v4.7 (#12478)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com>
Co-authored-by: Aditya Tripathi <aditya@climactic.co>
2026-11-06 14:25:02 +01:00

25 lines
1.1 KiB
PHP

<?php
use App\Models\Application;
use App\Models\ApplicationSetting;
use Tests\TestCase;
uses(TestCase::class);
it('resolves the Bitbucket PR checkout commit', function (?string $configured, ?string $commit, string $expected) {
$application = Mockery::mock(Application::class)->makePartial();
$application->forceFill(['git_branch' => 'main', 'git_commit_sha' => $configured]);
$application->setRelation('settings', new ApplicationSetting);
$application->shouldReceive('deploymentType')->andReturn('other');
$application->shouldReceive('customRepository')->andReturn(['repository' => 'https://bitbucket.org/example/repo.git', 'port' => 22]);
$result = $application->generateGitImportCommands('test-deployment', pull_request_id: 1, git_type: 'bitbucket', exec_in_docker: false, commit: $commit);
expect($result['commands'])->toContain("git checkout '{$expected}'");
})->with([
'configured commit' => ['abc1234', null, 'abc1234'],
'HEAD fallback' => [null, null, 'HEAD'],
'empty fallback' => ['', '', 'HEAD'],
'explicit commit' => ['abc1234', 'def5678', 'def5678'],
]);