-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Problem Statement
Modify the GitHubRepoConnector to support better testing.
Proposed Solution
It should be possible to significantly improve the testing of the GitHubRepoConnector by being able to have testing code provide it an HttpClient pre-loaded with GraphQL responses for its GitHubGraphQLClient.
One approach may be to move the new GitHubGraphQLClient(token) to a virtual function (say CreateGraphQLClient). That way testing can be done by deriving from GitHubRepoConnector and overriding the RunCommandAsync and CreateGraphQLClient methods.
That would allow the derived class to totally control git/gh command execution so GitHubRepoConnector gets fed mock data about the repo and token, and then the drived class can construct a GitHubGraphQLClient with an HttpClient pre-loaded with mock data about the repo.
This would allow completely testing the GitHubRepoConnectors GetBuildInformationAsync method.
One thing to consider is if a helper class should be created that can better mock the HttpClient message handling. That way many tests could in theory use this same helper to create convincing GitHub GraphQL response data for tests.
Alternatives Considered
No response
Usage Examples
Benefits
Improved testing and code coverage.
Priority
Medium - Would improve my workflow
Willingness to Contribute
Yes, I can submit a pull request
Additional Context
No response
Checklist
- I have searched existing issues to ensure this is not a duplicate
- I have provided a clear description of the feature
- I have explained why this feature would be useful