Skip to content

Commit 1ec6598

Browse files
committed
Fix avatar tests
1 parent ca20dfa commit 1ec6598

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

docker-compose.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ services:
6464
command: >
6565
-c "
6666
su git -c \"gitea admin user create --username $$GITEA_ADMIN_USERNAME --password $$GITEA_ADMIN_PASSWORD --email $$GITEA_ADMIN_EMAIL --admin --must-change-password=false\" || true &&
67-
TOKEN=$$(su git -c \"gitea admin user generate-access-token --username $$GITEA_ADMIN_USERNAME --token-name $$GITEA_ADMIN_USERNAME-token --scopes all --raw\") &&
68-
echo $$TOKEN > /data/gitea/token.txt
67+
if [ ! -f /data/gitea/token.txt ]; then
68+
TOKEN=$$(su git -c \"gitea admin user generate-access-token --username $$GITEA_ADMIN_USERNAME --token-name $$GITEA_ADMIN_USERNAME-token --scopes all --raw\") &&
69+
echo $$TOKEN > /data/gitea/token.txt;
70+
fi
6971
"
7072
request-catcher:
7173
image: appwrite/requestcatcher:1.1.0
@@ -107,8 +109,10 @@ services:
107109
command: >
108110
-c "
109111
su git -c \"forgejo admin user create --username $$FORGEJO_ADMIN_USERNAME --password $$FORGEJO_ADMIN_PASSWORD --email $$FORGEJO_ADMIN_EMAIL --admin --must-change-password=false\" || true &&
110-
TOKEN=$$(su git -c \"forgejo admin user generate-access-token --username $$FORGEJO_ADMIN_USERNAME --token-name $$FORGEJO_ADMIN_USERNAME-token --scopes all --raw\") &&
111-
echo $$TOKEN > /data/gitea/token.txt
112+
if [ ! -f /data/gitea/token.txt ]; then
113+
TOKEN=$$(su git -c \"forgejo admin user generate-access-token --username $$FORGEJO_ADMIN_USERNAME --token-name $$FORGEJO_ADMIN_USERNAME-token --scopes all --raw\") &&
114+
echo $$TOKEN > /data/gitea/token.txt;
115+
fi
112116
"
113117
114118
volumes:

tests/VCS/Adapter/ForgejoTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class ForgejoTest extends GiteaTest
1616

1717
protected string $webhookEventHeader = 'X-Forgejo-Event';
1818
protected string $webhookSignatureHeader = 'X-Forgejo-Signature';
19+
protected string $avatarDomain = 'http://localhost:3000/avatars/';
1920

2021
protected function createVCSAdapter(): Git
2122
{

tests/VCS/Adapter/GiteaTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class GiteaTest extends Base
1616

1717
protected string $webhookEventHeader = 'X-Gitea-Event';
1818
protected string $webhookSignatureHeader = 'X-Gitea-Signature';
19+
protected string $avatarDomain = 'gravatar.com';
1920

2021
protected function createVCSAdapter(): Git
2122
{
@@ -749,7 +750,7 @@ public function testGetCommit(): void
749750
$this->assertSame($commitHash, $result['commitHash']);
750751
$this->assertSame('utopia', $result['commitAuthor']);
751752
$this->assertStringStartsWith($customMessage, $result['commitMessage']);
752-
$this->assertStringContainsString('gravatar.com', $result['commitAuthorAvatar']);
753+
$this->assertStringContainsString($this->avatarDomain, $result['commitAuthorAvatar']);
753754
$this->assertNotEmpty($result['commitUrl']);
754755

755756
$this->vcsAdapter->deleteRepository(static::$owner, $repositoryName);
@@ -777,7 +778,7 @@ public function testGetLatestCommit(): void
777778
$this->assertNotEmpty($commit1['commitHash']);
778779
$this->assertSame('utopia', $commit1['commitAuthor']);
779780
$this->assertStringStartsWith($firstMessage, $commit1['commitMessage']);
780-
$this->assertStringContainsString('gravatar.com', $commit1['commitAuthorAvatar']);
781+
$this->assertStringContainsString($this->avatarDomain, $commit1['commitAuthorAvatar']);
781782
$this->assertNotEmpty($commit1['commitUrl']);
782783

783784
$commit1Hash = $commit1['commitHash'];

0 commit comments

Comments
 (0)