Skip to content

Add unit tests for internal/github issue comments and assignee management calls #41

Description

@Jagadeeshftw

📌 Description

internal/github/issues_comments.go (CreateIssueComment, DeleteIssueComment) and internal/github/assignees.go (AddIssueAssignees, RemoveIssueAssignees) drive the issue-application workflow (apply, assign, unassign, withdraw, reject) but have no tests. These are the actions a maintainer triggers from internal/handlers/issue_applications.go.

💡 Why it matters: Incorrect request shapes or unhandled error statuses here corrupt the visible state on contributors' GitHub issues; tests pin the HTTP contract.

🧩 Requirements and context

  • Use httptest.Server to assert request method, path, and JSON body for each call.
  • Cover success, 404 (missing issue), and 403 (permission) responses with appropriate error mapping.
  • Confirm assignees are sent as the GitHub-expected {"assignees": [...]} shape.
  • Confirm the comment body is sent as {"body": "..."}.
  • No real GitHub network access.

Non-functional requirements

  • Must be secure, tested, and documented.
  • Should be efficient and easy to review.

🛠️ Suggested execution

1. Fork the repo and create a branch

git checkout -b test/github-comments-assignees

2. Implement changes

  • Write/modify the relevant source: small refactor to inject base URL if needed
  • Write comprehensive tests: internal/github/issues_comments_test.go, internal/github/assignees_test.go
  • Add documentation: GoDoc on the request shapes
  • Include GoDoc comments on error mapping
  • Validate security assumptions: token header set, not logged

3. Test and commit

  • Run tests:
go test ./internal/github/...
  • Cover edge cases: 404, 403, empty assignee list, server 500
  • Include test output and security notes in the PR description.

Example commit message

test(github): cover issue comment and assignee API calls

✅ Acceptance criteria

  • Request method/path/body asserted for all four functions
  • Success and error statuses mapped and tested
  • Assignee/comment JSON shapes verified
  • No real network calls

🔒 Security notes

Verifies the Authorization header is set and never appears in logs or test output.

📋 Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSGrantFox open-source programMaybe RewardedGrantFox: potentially rewarded contributionOfficial CampaignGrantFox official campaign issuebackendBackend / API worktestingTests and coverage

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions