initial unified base tests#106
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5f46cf912a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Greptile SummaryThis PR consolidates shared adapter tests into
Confidence Score: 5/5Safe to merge; changes are confined to test infrastructure and one clarifying non-functional tightening of a GitLab adapter method. The production code change (GitLab getOwnerName) removes a fallback path that was acknowledged as intentionally wrong, and all call sites within the repo now pass a valid repositoryId. The test consolidation is mechanical and well-structured. The two findings are both cosmetic: a stale comment and a missing finally in a Gitea-only test override. tests/VCS/Adapter/GiteaTest.php — stale comment and missing finally in testGetRepositoryName. Important Files Changed
Reviews (8): Last reviewed commit: "Merge branch 'main' of https://github.co..." | Re-trigger Greptile |
| throw new Exception("repositoryId is required for this adapter"); | ||
| } | ||
|
|
||
| $url = "/user"; |
There was a problem hiding this comment.
Same comment as in PR #108, I dont think we can do this change as it would break Appwrite implementation
There was a problem hiding this comment.
Ran agent here too for noticing lost tests, here is result. Might be same as the other PR, I just noticed a lot of changes are similar.
I did a systematic comparison of every test method across the old adapter files, the new adapter files, and the rewritten Base.php. Here are the mistakes I found in the migration:
🔴 Critical: Fatal PHP Error in GitHubTest.php
testGetOwnerName() is declared twice in tests/VCS/Adapter/GitHubTest.php (at lines ~681 and ~779).
PHP will throw a fatal error when the class is loaded:
Fatal error: Cannot redeclare Utopia\Tests\Adapter\GitHubTest::testGetOwnerName()
This is a clear copy-paste artifact from the migration and will prevent the GitHub test suite from running at all.
🟠 Lost Coverage: testCreateRepositoryWithInvalidName
What was removed:
Old GiteaTest had a testCreateRepositoryWithInvalidName() test that verified creating a repo with spaces in the name throws an exception.
Where it went:
- Removed from GiteaTest (and therefore from ForgejoTest, which extends it).
- Not added to Base.php.
- It only survives in GitLabTest.
Impact:
GiteaTest and ForgejoTest no longer verify invalid-name rejection. Because this was a shared test (both Gitea and GitLab had it), it should have been moved to Base.php so all adapters run it.
🟡 Lost Coverage: testGetOwnerNameWithRepositoryId
What was removed:
Old GitLabTest had testGetOwnerNameWithRepositoryId(), which:
- Created a repository.
- Fetched it back via getRepository().
- Used that repository ID to call getOwnerName().
Where it went:
- Removed from GitLabTest.
- Not added to Base.php.
Impact:
Base.php does have testGetOwnerName(), but it uses the ID returned directly from createRepository(). It does not exercise the getRepository → getOwnerName path, so that specific integration is no longer tested for GitLab.
🟡 Unsafe Override Left in GiteaTest
GiteaTest still overrides testGetRepositoryName() even though Base.php now provides a generic version. The Gitea override does not wrap cleanup in try/finally:
// GiteaTest (current)
$this->assertTrue($this->vcsAdapter->deleteRepository(static::$owner, $repositoryName));
// Base.php (safer)
try { ... } finally {
$this->vcsAdapter->deleteRepository(static::$owner, $repositoryName);
}
If getRepositoryName() throws, the Gitea override leaks the test repository. This override should be deleted so the safer Base test runs.
🟡 Incomplete Duplicate Removal in GitHubTest
While not fatal, many tests that now exist identically in Base.php are still duplicated in GitHubTest.php (e.g. testGetLatestCommit, testUpdateCommitStatus, testGenerateCloneCommand, testGenerateCloneCommandWithCommitHash, testGenerateCloneCommandWithInvalidRepository). Because they override the Base methods, the unified Base tests are never actually executed for GitHub, which partially defeats the purpose of the migration.
TL;DR
Issue File Severity
Duplicate method testGetOwnerName GitHubTest.php Fatal
testCreateRepositoryWithInvalidName removed, not in Base GiteaTest Coverage lost
testGetOwnerNameWithRepositoryId removed, not in Base GitLabTest Coverage lost
Unsafe testGetRepositoryName override kept GiteaTest Leaks repos on failure

Migrates all shared adapter tests into Base.php following the dynamic pattern. All tests now create repos dynamically with uniqid() and clean up in finally blocks — no hardcoded owners, repos, or IDs.
Key changes:
Base.php fully rewritten with shared dynamic tests covering repository CRUD, tree, content, branches, commits, clone commands, pull requests, comments, search and owner
All adapter files implement setupAdapter() instead of setUp()
static::$owner and static::$defaultBranch used throughout
Duplicate tests removed from GiteaTest, GitLabTest, GitHubTest
Adapter-specific tests kept only where behavior genuinely differs
getOwnerName made consistent across GitLab and Gitea — requires repositoryId
Admin username changed to root across all adapters for consistency
testListBranchesEmptyRepo skipped in Base — each adapter overrides correctly