Skip to content

test: rewrite GitHub adapter tests to be fully dynamic#95

Merged
ChiragAgg5k merged 6 commits into
utopia-php:mainfrom
jaysomani:feat/github-tests-rewrite
May 13, 2026
Merged

test: rewrite GitHub adapter tests to be fully dynamic#95
ChiragAgg5k merged 6 commits into
utopia-php:mainfrom
jaysomani:feat/github-tests-rewrite

Conversation

@jaysomani
Copy link
Copy Markdown
Contributor

Rewrites GitHubTest.php from hardcoded fixtures to fully dynamic tests following the same pattern as GitLab and Gitea adapters.
Changes:

All tests now create repositories dynamically with uniqid() and clean up in finally blocks
Owner resolved dynamically via getOwnerName() — works with any GitHub App installation, no hardcoding
setUp now skips gracefully when credentials are missing instead of erroring
Added str_replace('\n', "\n", ...) in setUp for local env compatibility (no-op on CI)
35 dynamic tests passing, 7 skipped (require createBranch/createPullRequest which are not implemented in GitHub adapter)

Also fixes in GitHub.php:

getRepository now throws RepositoryNotFound on 404 instead of returning raw error response
getCommit now throws RepositoryNotFound on 404/422 instead of returning empty commit struct

New tests added: testCreatePrivateRepository, testGetDeletedRepositoryFails, testDeleteRepository, testDeleteNonExistingRepositoryFails, testGetRepositoryNameWithInvalidId, testGetRepositoryTreeWithInvalidBranch, testGetRepositoryContentWithRef, testGetRepositoryContentFileNotFound, testGetRepositoryContentCaseSensitive, testListRepositoryContentsNonExistingPath, testListRepositoryLanguages, testListBranches, testGetCommitWithInvalidHash, testGetLatestCommitWithInvalidBranch, testUpdateCommitStatus, testGenerateCloneCommandWithInvalidRepository, testGetOwnerName, testSearchRepositories, testValidateWebhookEvent, testGetEventInstallation
Note: testGenerateCloneCommandWithTag (wildcard tags) not included as createTag is not implemented in GitHub adapter.

@jaysomani jaysomani marked this pull request as ready for review April 28, 2026 10:19
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 28, 2026

Greptile Summary

This PR rewrites GitHubTest.php from hardcoded fixtures to fully dynamic tests (using uniqid() repos with try/finally cleanup), and fixes getRepository, getCommit, and getLatestCommit in GitHub.php to throw on 404/422 instead of silently returning empty results. All remaining findings are P2: getCommit and getLatestCommit reuse RepositoryNotFound for commit/branch 404s (misleading to callers that catch that specific type), and four "error path" tests place expectException inside a try/finally block where a transient failure in the finally cleanup can swallow the expected exception.

Confidence Score: 5/5

Safe to merge; all findings are P2 and do not affect production runtime behavior.

No P0 or P1 issues found. The two P2 findings (semantic misuse of RepositoryNotFound and expectException inside try/finally) are quality concerns that do not cause production failures or test failures under normal CI conditions.

Minor attention to src/VCS/Adapter/Git/GitHub.php lines 775-776 and 813-814 for the RepositoryNotFound semantic issue.

Important Files Changed

Filename Overview
src/VCS/Adapter/Git/GitHub.php Adds 404/422 error guards to getRepository, getCommit, and getLatestCommit; getCommit and getLatestCommit incorrectly reuse RepositoryNotFound for commit/branch 404s.
tests/VCS/Adapter/GitHubTest.php Full rewrite to dynamic tests with uniqid() repos and try/finally cleanup; four tests use expectException inside a try/finally block, which can be swallowed by a deleteRepository exception in the finally clause.

Reviews (3): Last reviewed commit: "uupdated with lint" | Re-trigger Greptile

Comment thread tests/VCS/Adapter/GitHubTest.php
Comment thread tests/VCS/Adapter/GitHubTest.php
Comment thread src/VCS/Adapter/Git/GitHub.php
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 706a5362e0

ℹ️ 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".

Comment thread src/VCS/Adapter/Git/GitHub.php Outdated
Comment thread tests/VCS/Adapter/GitHubTest.php
@Meldiron Meldiron added the test Enables E2E tests in CI/CD label Apr 30, 2026
@Meldiron Meldiron added test Enables E2E tests in CI/CD and removed test Enables E2E tests in CI/CD labels May 12, 2026
@ChiragAgg5k ChiragAgg5k merged commit c14ec4d into utopia-php:main May 13, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test Enables E2E tests in CI/CD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants