Skip to content

Commit 2548e9b

Browse files
Improve test coverage, refactor to modern test patterns, and improve encapsulation (#91)
* Initial plan * Remove 19 redundant tests for internal methods now covered by integration tests Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com> * Add comprehensive tests for ProcessRunner and enhance MockRepoConnector coverage Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com> * Fix XML documentation to match test implementation Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com> * Refactor exception test to move assertions outside catch block Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com> * Make collection parameters use params to simplify caller syntax Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com> * Use Assert.ThrowsAsync pattern and make untested methods private Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
1 parent 2c9e388 commit 2548e9b

File tree

6 files changed

+365
-476
lines changed

6 files changed

+365
-476
lines changed

src/DemaConsulting.BuildMark/RepoConnectors/GitHubRepoConnector.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ private static async Task<GitHubData> FetchGitHubDataAsync(
240240
/// </summary>
241241
/// <param name="data">GitHub data.</param>
242242
/// <returns>Container with all lookup data structures.</returns>
243-
internal static LookupData BuildLookupData(GitHubData data)
243+
private static LookupData BuildLookupData(GitHubData data)
244244
{
245245
// Build a mapping from issue number to issue for efficient lookup.
246246
// This is used to look up issue details when we find linked issue IDs.
@@ -303,7 +303,7 @@ internal static LookupData BuildLookupData(GitHubData data)
303303
/// <param name="lookupData">Lookup data structures.</param>
304304
/// <returns>Tuple of (toVersion, toHash).</returns>
305305
/// <exception cref="InvalidOperationException">Thrown if version cannot be determined.</exception>
306-
internal static (Version toVersion, string toHash) DetermineTargetVersion(
306+
private static (Version toVersion, string toHash) DetermineTargetVersion(
307307
Version? version,
308308
string currentCommitHash,
309309
LookupData lookupData)
@@ -350,7 +350,7 @@ internal static (Version toVersion, string toHash) DetermineTargetVersion(
350350
/// <param name="toVersion">Target version.</param>
351351
/// <param name="lookupData">Lookup data structures.</param>
352352
/// <returns>Tuple of (fromVersion, fromHash).</returns>
353-
internal static (Version? fromVersion, string? fromHash) DetermineBaselineVersion(
353+
private static (Version? fromVersion, string? fromHash) DetermineBaselineVersion(
354354
Version toVersion,
355355
LookupData lookupData)
356356
{
@@ -728,7 +728,7 @@ private static async Task<IReadOnlyList<IssueInfo>> GetAllIssuesAsync(
728728
/// <param name="fromHash">Starting commit hash (exclusive - not included in results; null for start of history).</param>
729729
/// <param name="toHash">Ending commit hash (inclusive - included in results).</param>
730730
/// <returns>List of commits in range, excluding fromHash but including toHash.</returns>
731-
internal static List<Commit> GetCommitsInRange(IReadOnlyList<Commit> commits, string? fromHash, string toHash)
731+
private static List<Commit> GetCommitsInRange(IReadOnlyList<Commit> commits, string? fromHash, string toHash)
732732
{
733733
// Initialize collection and state tracking
734734
var result = new List<Commit>();
@@ -766,7 +766,7 @@ internal static List<Commit> GetCommitsInRange(IReadOnlyList<Commit> commits, st
766766
/// <param name="issue">GitHub issue.</param>
767767
/// <param name="index">Index for sorting.</param>
768768
/// <returns>ItemInfo instance.</returns>
769-
internal static ItemInfo CreateItemInfoFromIssue(IssueInfo issue, int index)
769+
private static ItemInfo CreateItemInfoFromIssue(IssueInfo issue, int index)
770770
{
771771
// Determine item type from issue labels
772772
var type = GetTypeFromLabels(issue.Labels);
@@ -785,7 +785,7 @@ internal static ItemInfo CreateItemInfoFromIssue(IssueInfo issue, int index)
785785
/// </summary>
786786
/// <param name="pr">GitHub pull request.</param>
787787
/// <returns>ItemInfo instance.</returns>
788-
internal static ItemInfo CreateItemInfoFromPullRequest(PullRequestInfo pr)
788+
private static ItemInfo CreateItemInfoFromPullRequest(PullRequestInfo pr)
789789
{
790790
// Determine item type from PR labels
791791
var type = GetTypeFromLabels(pr.Labels);
@@ -804,7 +804,7 @@ internal static ItemInfo CreateItemInfoFromPullRequest(PullRequestInfo pr)
804804
/// </summary>
805805
/// <param name="labels">List of issue labels.</param>
806806
/// <returns>Item type string.</returns>
807-
internal static string GetTypeFromLabels(IReadOnlyList<IssueLabelInfo> labels)
807+
private static string GetTypeFromLabels(IReadOnlyList<IssueLabelInfo> labels)
808808
{
809809
// Find first matching label type by checking label names against the type map
810810
var matchingType = labels
@@ -823,7 +823,7 @@ internal static string GetTypeFromLabels(IReadOnlyList<IssueLabelInfo> labels)
823823
/// </summary>
824824
/// <param name="labels">List of pull request labels.</param>
825825
/// <returns>Item type string.</returns>
826-
internal static string GetTypeFromLabels(IReadOnlyList<PullRequestLabelInfo> labels)
826+
private static string GetTypeFromLabels(IReadOnlyList<PullRequestLabelInfo> labels)
827827
{
828828
// Find first matching label type by checking label names against the type map
829829
var matchingType = labels
@@ -867,7 +867,7 @@ private async Task<string> GetGitHubTokenAsync()
867867
/// <param name="url">Git remote URL.</param>
868868
/// <returns>Tuple of (owner, repo).</returns>
869869
/// <exception cref="ArgumentException">Thrown if URL format is invalid.</exception>
870-
internal static (string owner, string repo) ParseGitHubUrl(string url)
870+
private static (string owner, string repo) ParseGitHubUrl(string url)
871871
{
872872
// Normalize URL by trimming whitespace
873873
url = url.Trim();
@@ -895,7 +895,7 @@ internal static (string owner, string repo) ParseGitHubUrl(string url)
895895
/// <param name="path">Path segment (e.g., "owner/repo.git").</param>
896896
/// <returns>Tuple of (owner, repo).</returns>
897897
/// <exception cref="ArgumentException">Thrown if path format is invalid.</exception>
898-
internal static (string owner, string repo) ParseOwnerRepo(string path)
898+
private static (string owner, string repo) ParseOwnerRepo(string path)
899899
{
900900
// Remove .git suffix if present
901901
if (path.EndsWith(".git", StringComparison.OrdinalIgnoreCase))
@@ -923,7 +923,7 @@ internal static (string owner, string repo) ParseOwnerRepo(string path)
923923
/// <param name="newTag">New tag name.</param>
924924
/// <param name="branchTagNames">Set of tag names on the current branch.</param>
925925
/// <returns>WebLink to GitHub compare page, or null if no baseline tag or if tags not found in branch.</returns>
926-
internal static WebLink? GenerateGitHubChangelogLink(string owner, string repo, string? oldTag, string newTag, HashSet<string> branchTagNames)
926+
private static WebLink? GenerateGitHubChangelogLink(string owner, string repo, string? oldTag, string newTag, HashSet<string> branchTagNames)
927927
{
928928
// Cannot generate comparison link without a baseline tag
929929
if (oldTag == null)

0 commit comments

Comments
 (0)