Skip to content

test: add tests for Gitea comment operations#73

Merged
Meldiron merged 3 commits into
utopia-php:mainfrom
jaysomani:feat/gitea-comment-tests
Mar 20, 2026
Merged

test: add tests for Gitea comment operations#73
Meldiron merged 3 commits into
utopia-php:mainfrom
jaysomani:feat/gitea-comment-tests

Conversation

@jaysomani

Copy link
Copy Markdown
Contributor
  • Implement testCreateComment with PR creation and verification
  • Implement testUpdateComment with comment modification flow
  • Add try/finally cleanup to prevent test repository leaks
  • Remove skipped test markers for createComment and updateComment

- Implement testCreateComment with PR creation and verification
- Implement testUpdateComment with comment modification flow
- Add try/finally cleanup to prevent test repository leaks
- Remove skipped test markers for createComment and updateComment
@greptile-apps

greptile-apps Bot commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR implements testCreateComment and testUpdateComment for the Gitea adapter by replacing markTestSkipped stubs with full test flows: creating a temporary repository, branching, filing a PR, exercising the comment API, and cleaning up via try/finally.

  • Both tests correctly exercise the full comment lifecycle (create → verify → update → verify) and assert on the returned comment ID type and content.
  • createRepository is called outside the try/finally block in both new tests. While there is currently no code between that call and the try block (making it functionally safe), the pattern is fragile — any future addition in that gap would leak the repository on failure. Moving createRepository inside try is the safer approach.
  • assertNotEmpty($commentId) in testCreateComment relies on PHP's empty() semantics, which considers the string '0' as empty. Although Gitea comment IDs are unlikely to be 0 in practice, assertNotEquals('', $commentId) would be a more precise assertion.
  • The two new tests share nearly identical setup code (repo creation, file, branch, PR); extracting this into a private helper method would reduce duplication and make future test additions easier.

Confidence Score: 4/5

  • Safe to merge — the tests are functionally correct and the issues are minor defensive/style concerns.
  • The new tests implement the intended behaviour correctly, use proper try/finally cleanup, and assert on meaningful values. The only concerns are: createRepository sitting outside the try block (no code gap today, but fragile for future edits) and assertNotEmpty's falsy-string edge case with '0'. Neither is a runtime bug in the current state.
  • No files require special attention.

Important Files Changed

Filename Overview
tests/VCS/Adapter/GiteaTest.php Implements testCreateComment and testUpdateComment with full PR lifecycle setup and try/finally cleanup; minor issues with createRepository placement outside the try block and assertNotEmpty's falsy-string sensitivity.

Last reviewed commit: "test: add tests for ..."

Comment thread tests/VCS/Adapter/GiteaTest.php
Comment thread tests/VCS/Adapter/GiteaTest.php
Comment thread tests/VCS/Adapter/GiteaTest.php
@Meldiron Meldiron added the test Enables E2E tests in CI/CD label Mar 20, 2026
@Meldiron Meldiron added test Enables E2E tests in CI/CD and removed test Enables E2E tests in CI/CD labels Mar 20, 2026
@Meldiron Meldiron merged commit d18eda2 into utopia-php:main Mar 20, 2026
4 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.

2 participants