forked from utopia-php/vcs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGogsTest.php
More file actions
133 lines (115 loc) · 3.88 KB
/
GogsTest.php
File metadata and controls
133 lines (115 loc) · 3.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
namespace Utopia\Tests\Adapter;
use Utopia\Cache\Adapter\None;
use Utopia\Cache\Cache;
use Utopia\System\System;
use Utopia\VCS\Adapter\Git;
use Utopia\VCS\Adapter\Git\Gogs;
class GogsTest extends GiteaTest
{
protected static string $accessToken = '';
protected static string $owner = '';
protected string $webhookEventHeader = 'X-Gogs-Event';
protected string $webhookSignatureHeader = 'X-Gogs-Signature';
protected string $avatarDomain = 'gravatar.com';
protected static string $defaultBranch = 'master';
protected function createVCSAdapter(): Git
{
return new Gogs(new Cache(new None()));
}
public function setUp(): void
{
if (empty(static::$accessToken)) {
$this->setupGogs();
}
$adapter = new Gogs(new Cache(new None()));
$gogsUrl = System::getEnv('TESTS_GOGS_URL', 'http://gogs:3000');
$adapter->initializeVariables(
installationId: '',
privateKey: '',
appId: '',
accessToken: static::$accessToken,
refreshToken: ''
);
$adapter->setEndpoint($gogsUrl);
if (empty(static::$owner)) {
$orgName = 'test-org-' . \uniqid();
static::$owner = $adapter->createOrganization($orgName);
}
$this->vcsAdapter = $adapter;
}
protected function setupGogs(): void
{
$tokenFile = '/gogs-data/gogs/token.txt';
if (file_exists($tokenFile)) {
$contents = file_get_contents($tokenFile);
if ($contents !== false) {
static::$accessToken = trim($contents);
}
}
}
// --- Skip tests for unsupported Gogs features ---
// Pull request API
public function testCommentWorkflow(): void
{
$this->markTestSkipped('Gogs does not support pull request API');
}
public function testGetComment(): void
{
$this->markTestSkipped('Gogs does not support pull request API');
}
public function testGetPullRequest(): void
{
$this->markTestSkipped('Gogs does not support pull request API');
}
public function testGetPullRequestWithInvalidNumber(): void
{
$this->markTestSkipped('Gogs does not support pull request API');
}
public function testGetPullRequestFromBranch(): void
{
$this->markTestSkipped('Gogs does not support pull request API');
}
public function testGetPullRequestFromBranchNoPR(): void
{
$this->markTestSkipped('Gogs does not support pull request API');
}
public function testUpdateComment(): void
{
$this->markTestSkipped('Gogs does not support pull request API');
}
public function testCreateComment(): void
{
$this->markTestSkipped('Gogs does not support pull request API');
}
public function testWebhookPullRequestEvent(): void
{
$this->markTestSkipped('Gogs does not support pull request API');
}
// Commit status
public function testUpdateCommitStatus(): void
{
$this->markTestSkipped('Gogs does not support commit status API');
}
public function testUpdateCommitStatusWithInvalidCommit(): void
{
$this->markTestSkipped('Gogs does not support commit status API');
}
public function testUpdateCommitStatusWithNonExistingRepository(): void
{
$this->markTestSkipped('Gogs does not support commit status API');
}
// Repository languages
public function testListRepositoryLanguages(): void
{
$this->markTestSkipped('Gogs does not support repository languages endpoint');
}
public function testListRepositoryLanguagesEmptyRepo(): void
{
$this->markTestSkipped('Gogs does not support repository languages endpoint');
}
public function testGetPullRequestFiles(): void
{
$this->markTestSkipped('Gogs does not support pull request files API');
}
}