Skip to content

Test Coverage PR-2: Tests added in ./dispatch and ./github subdir.#233

Open
mohanmanikanta2299 wants to merge 4 commits into
mainfrom
mohan/test_coverage-2
Open

Test Coverage PR-2: Tests added in ./dispatch and ./github subdir.#233
mohanmanikanta2299 wants to merge 4 commits into
mainfrom
mohan/test_coverage-2

Conversation

@mohanmanikanta2299
Copy link
Copy Markdown
Collaborator

@mohanmanikanta2299 mohanmanikanta2299 commented Jun 5, 2026

🛠️ Description

Summary

This PR is the 2nd part of the test coverage PRs intended to increase the test coverage of the entire repo from 55% to 80+%, fulfilling our coverage requirements.

Changes Made

  • Implemented comprehensive table-driven tests for the ./github and ./dispatch package.
  • Added validation for CLI command flags, ensuring default values and flag bindings are properly configured (e.g., fields, github-org).
  • Added strict assertions (assert.Equal, assert.Contains) and explicit error checking to validate function outputs and edge cases.
  • Used require for critical initializations (like loggers and flag lookups) to prevent nil-pointer panics during test execution.

Testing

  • Ran go test -v ./... (All tests passing)
  • Ran go test -race ./... (No race conditions detected)
  • Verified coverage metrics locally.

🔗 External Links

https://hashicorp.atlassian.net/browse/CCEN-512

👍 Definition of Done

  • Tests added : ✅

🤔 Can be merged upon approval?

PCI review checklist

  • I have documented a clear reason for, and description of, the change I am making.

  • If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.

  • If applicable, I've documented the impact of any changes to security controls.

    Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.

Copilot AI review requested due to automatic review settings June 5, 2026 12:20
@mohanmanikanta2299 mohanmanikanta2299 requested a review from a team as a code owner June 5, 2026 12:20
@mohanmanikanta2299 mohanmanikanta2299 marked this pull request as draft June 5, 2026 12:21
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds new unit tests to raise coverage for the github/ and dispatch/ packages, focusing on GitHub auth configuration discovery and GitHub Actions workflow dispatch/polling helpers.

Changes:

  • Added table-driven tests for github repo discovery and repository-creation-year lookup.
  • Added tests for github client auth configuration fallbacks (GH App env/.env, GITHUB_TOKEN, and gh CLI config).
  • Added tests for dispatch workflow dispatch, run lookup, and completion polling logic using an httptest GitHub API.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
github/repo_test.go New tests for DiscoverRepo and GetRepoCreationYear.
github/client_test.go New tests for GH App config parsing and client auth fallback selection.
dispatch/dispatch_test.go New tests for dispatch worker flow and Actions run polling/lookup.

Comment thread github/repo_test.go Outdated
Comment thread github/client_test.go Outdated
Comment thread github/client_test.go Outdated
Comment thread github/client_test.go
@mohanmanikanta2299 mohanmanikanta2299 changed the title Test coverage in ./dispatch and ./github subdir. Test Coverage PR-2: Tests added in ./dispatch and ./github subdir. Jun 5, 2026
@mohanmanikanta2299 mohanmanikanta2299 marked this pull request as ready for review June 5, 2026 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants