Add ticket branch discovery by ticket key

This commit is contained in:
2026-03-26 09:16:17 +01:00
parent fee14d93a7
commit 0b95477f4e
12 changed files with 475 additions and 0 deletions
+37
View File
@@ -3,6 +3,7 @@
namespace Tests\Feature\Git;
use App\Actions\Git\Data\GitAuthenticatedUser;
use App\Actions\Git\Data\GitBranch;
use App\Actions\Git\Data\GitRepository;
use App\Actions\Git\Gitea\GiteaProviderClient;
use Illuminate\Foundation\Testing\RefreshDatabase;
@@ -80,4 +81,40 @@ class GiteaProviderTest extends TestCase
&& $request->hasHeader('Authorization', 'token repo-token');
});
}
/**
* Ensure the provider lists branches for a specific repository.
*/
public function test_provider_can_list_repository_branches(): void
{
Http::preventStrayRequests();
Http::fake([
'https://git.example.test/api/v1/repos/core-team/kanbangit/branches*' => Http::response([
[
'name' => 'CORE-1-login-form',
],
[
'name' => 'main',
],
]),
]);
$branches = app(GiteaProviderClient::class)->listBranches(
'https://git.example.test',
'branch-token',
'core-team',
'kanbangit',
);
$this->assertCount(2, $branches);
$this->assertContainsOnlyInstancesOf(GitBranch::class, $branches);
$this->assertSame('CORE-1-login-form', $branches[0]->name);
Http::assertSent(function ($request): bool {
return str_starts_with(
$request->url(),
'https://git.example.test/api/v1/repos/core-team/kanbangit/branches',
) && $request->hasHeader('Authorization', 'token branch-token');
});
}
}