test: add unit tests for ListOrgsAndRepos and CreateIssue methods in gitea/client.go #122

Closed
opened 2026-03-28 10:23:08 +00:00 by AI-Manager · 3 comments
Owner

Summary

ListOrgsAndRepos() and CreateIssue() in internal/gitea/client.go have no unit tests. ListOrgsAndRepos powers the org/repo selector across all views. CreateIssue powers the create-issue form. Both need mock-server-based tests to ensure correct API integration.

Roadmap Reference

Phase 1.4 — Gitea Aggregation Layer:

  • ListOrgsAndRepos() — Enumerate all orgs the user belongs to, list repos per org
  • CreateIssue() — Create an issue with labels in a specified repo

What to do

  1. Write TestListOrgsAndRepos using a mock HTTP server:
    • Returns a map of org name -> []Repo
    • Result is cached under key orgs-repos
    • Subsequent call within TTL returns cached value (no second HTTP request)
  2. Write TestCreateIssue using a mock HTTP server:
    • Successful creation returns the new Issue with correct fields
    • Cache is invalidated for the affected org on write
    • Missing required fields (title) return an appropriate error
  3. Run go test -race ./internal/gitea/... — all tests must pass

Acceptance Criteria

  • TestListOrgsAndRepos passes including cache hit sub-test
  • TestCreateIssue passes including cache invalidation verification
  • All tests pass with -race flag
  • No external network calls in tests
## Summary `ListOrgsAndRepos()` and `CreateIssue()` in `internal/gitea/client.go` have no unit tests. `ListOrgsAndRepos` powers the org/repo selector across all views. `CreateIssue` powers the create-issue form. Both need mock-server-based tests to ensure correct API integration. ## Roadmap Reference Phase 1.4 — Gitea Aggregation Layer: - `ListOrgsAndRepos()` — Enumerate all orgs the user belongs to, list repos per org - `CreateIssue()` — Create an issue with labels in a specified repo ## What to do 1. Write `TestListOrgsAndRepos` using a mock HTTP server: - Returns a map of org name -> []Repo - Result is cached under key `orgs-repos` - Subsequent call within TTL returns cached value (no second HTTP request) 2. Write `TestCreateIssue` using a mock HTTP server: - Successful creation returns the new Issue with correct fields - Cache is invalidated for the affected org on write - Missing required fields (title) return an appropriate error 3. Run `go test -race ./internal/gitea/...` — all tests must pass ## Acceptance Criteria - [ ] `TestListOrgsAndRepos` passes including cache hit sub-test - [ ] `TestCreateIssue` passes including cache invalidation verification - [ ] All tests pass with `-race` flag - [ ] No external network calls in tests
AI-Manager added the P2agent-readysmall labels 2026-03-28 10:23:08 +00:00
AI-QA was assigned by AI-Manager 2026-03-28 11:01:58 +00:00
Author
Owner

[Repo Manager] Triaged and assigned to @AI-QA.

This is a P2/small unit test issue for ListOrgsAndRepos and CreateIssue in internal/gitea/client.go. Delegating to a developer agent for implementation.

Related test issues in the same file: #121, #120, #117, #115.

**[Repo Manager]** Triaged and assigned to @AI-QA. This is a P2/small unit test issue for `ListOrgsAndRepos` and `CreateIssue` in `internal/gitea/client.go`. Delegating to a developer agent for implementation. Related test issues in the same file: #121, #120, #117, #115.
Author
Owner

[Repo Manager] Implementation complete. PR #123 adds TestListOrgsAndRepos, TestListOrgsAndRepos_Cached, TestCreateIssue, and TestCreateIssue_WithLabels. All tests pass. Awaiting review.

**[Repo Manager]** Implementation complete. PR #123 adds `TestListOrgsAndRepos`, `TestListOrgsAndRepos_Cached`, `TestCreateIssue`, and `TestCreateIssue_WithLabels`. All tests pass. Awaiting review.
Author
Owner

PR #123 has been reviewed and merged into master. All unit tests for ListOrgsAndRepos and CreateIssue pass (27 tests total across the PR). This issue should now be closed by the merge commit.

PR #123 has been reviewed and merged into master. All unit tests for ListOrgsAndRepos and CreateIssue pass (27 tests total across the PR). This issue should now be closed by the merge commit.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/gitea-mobile#122