-
Notifications
You must be signed in to change notification settings - Fork 8
fix(bitbucket): name a project when the workspace won't pick one #131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
62e8fff
0fd9b98
0cfd652
ce1c834
fd7f0d9
ee6922f
7496330
16b6af2
f397ec7
0c88b47
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| use Utopia\Cache\Cache; | ||
| use Utopia\System\System; | ||
| use Utopia\Tests\Base; | ||
| use Exception; | ||
| use Utopia\VCS\Adapter\Git\Bitbucket; | ||
|
|
||
| class BitbucketTest extends Base | ||
|
|
@@ -45,6 +46,10 @@ class BitbucketTest extends Base | |
| // Bitbucket Cloud can't reach a local test catcher | ||
| protected static bool $supportsWebhookDelivery = false; | ||
|
|
||
| // Projects are Bitbucket's alone, so they are reached off the adapter | ||
| // itself rather than through the shared contract | ||
| private Bitbucket $bitbucket; | ||
|
Comment on lines
+49
to
+51
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets try to make Appwrite PR. Curious what this casting will look like there, for bitbuket specific behaviour
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Worried this will be trouble, but not sure. Maybe PHP has some magic to make it nice |
||
|
|
||
| protected function signWebhookPayload(string $payload, string $secret): string | ||
| { | ||
| return 'sha256=' . hash_hmac('sha256', $payload, $secret); | ||
|
|
@@ -75,6 +80,7 @@ protected function setupAdapter(): void | |
| } | ||
|
|
||
| $this->vcsAdapter = $adapter; | ||
| $this->bitbucket = $adapter; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -171,10 +177,50 @@ private function eventActor(): array | |
| ]; | ||
| } | ||
|
|
||
| /** | ||
| * Bitbucket only names the author in a raw "Name <email>" string; a commit | ||
| * linked to an account is named by the account instead. | ||
| */ | ||
| public function testCreateRepositoryProject(): void | ||
| { | ||
| // Naming no project files the repository under the workspace default, | ||
| // which is also the only place an existing key can be read from | ||
| $withoutProject = 'test-create-repository-no-project-' . \uniqid(); | ||
| $repository = $this->bitbucket->createRepository(static::$owner, $withoutProject, false); | ||
|
|
||
| try { | ||
| $this->assertSame($withoutProject, $repository['name']); | ||
| $this->assertArrayHasKey('project', $repository); | ||
| $this->assertIsArray($repository['project']); | ||
| $this->assertArrayHasKey('key', $repository['project']); | ||
| $this->assertIsString($repository['project']['key']); | ||
| $projectKey = $repository['project']['key']; | ||
| } finally { | ||
| $this->discardRepositories($withoutProject); | ||
| } | ||
|
|
||
| $inProject = 'test-create-repository-project-' . \uniqid(); | ||
| $repository = $this->bitbucket->createRepository(static::$owner, $inProject, false, $projectKey); | ||
|
|
||
| try { | ||
| $this->assertSame($inProject, $repository['name']); | ||
| $this->assertArrayHasKey('project', $repository); | ||
| $this->assertIsArray($repository['project']); | ||
| $this->assertArrayHasKey('key', $repository['project']); | ||
| $this->assertSame($projectKey, $repository['project']['key']); | ||
| } finally { | ||
| $this->discardRepositories($inProject); | ||
| } | ||
| } | ||
|
|
||
| public function testCreateRepositoryInAnUnknownProjectFails(): void | ||
|
Meldiron marked this conversation as resolved.
|
||
| { | ||
| $this->expectException(Exception::class); | ||
|
|
||
| $this->bitbucket->createRepository( | ||
| static::$owner, | ||
| 'test-create-repository-unknown-project-' . \uniqid(), | ||
| false, | ||
| 'NOSUCHPROJECTKEY' | ||
| ); | ||
| } | ||
|
|
||
| public function testGetEventPushWithLinkedAuthor(): void | ||
| { | ||
| $payload = json_decode($this->pushPayload(static::$defaultBranch), true); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.