Skip to content

Round 4: Boost unit test coverage across docs, common, gitlab/scan, and logging packages#538

Open
Copilot wants to merge 7 commits intomainfrom
copilot/deep-test-analysis-go-project
Open

Round 4: Boost unit test coverage across docs, common, gitlab/scan, and logging packages#538
Copilot wants to merge 7 commits intomainfrom
copilot/deep-test-analysis-go-project

Conversation

Copy link
Contributor

Copilot AI commented Mar 3, 2026

Four successive rounds of testability refactoring to systematically increase unit test coverage from ~46% to ~51% total, each round identifying untested patterns, refactoring for injectability, and adding focused tests.

Refactoring patterns addressed across all rounds

HTTP client injection — inline httpclient.GetPipeleekHTTPClient(...) calls made all error/success paths unreachable without a live network. Extracted to parameters on:

  • FetchCurrentSelfHostedOptions, ExtendRenovateConfig, ValidateRenovateConfigService (pkg/renovate)
  • downloadFile (pkg/scanner/rules)

Duplicate implementations eliminatedpkg/gitlab/renovate/enum had local copies of validateRenovateConfigService and fetchCurrentSelfHostedOptions (each ~20 lines). Replaced with single-line delegations to the shared implementations.

Pure functions with untested branchesvalidateOrderBy, deduplicateFindingsWithState, formatLevelWithHitColor, fetchVersionFromHTML, dumpConfigFileContents refactored to return errors or accept injected deps instead of logging fatally.

Round 4 additions (this commit)

  • pkg/docs (50% → 72.2%): generateDocs (leaf, parent, GitHub Pages link rewriting, unwritable dir) and inlineSVGIntoGettingStarted (missing file, no placeholder early-return, missing SVG, full replacement)
  • internal/cmd/common (50% → 70.8%): InitLogger in console/JSON/no-logfile modes; SaveTerminalState / RestoreTerminalState no-panic paths
  • pkg/gitlab/scan (22.8% → 32.1%): setupQueue (default tempdir, relative, absolute); GetQueueStatus nil/non-nil globQueue; analyzeQueueItem unknown-type dispatch and invalid-JSON error path
  • pkg/logging (62.5% → 68.8%): setupGlobalHitWriter via the Hit() nil-writer branch; idempotent sync.Once concurrent init

Coverage delta across all rounds

Package Start End Δ
pkg/renovate 83.0% 93.2% +10.2%
internal/cmd 75.7% 89.2% +13.5%
internal/cmd/common 50.0% 70.8% +20.8%
pkg/docs 50.0% 72.2% +22.2%
pkg/gitlab/scan 22.8% 32.1% +9.3%
pkg/scanner/rules 84.9% 88.5% +3.6%
pkg/logging 62.5% 68.8% +6.3%
Total ~46.8% ~50.9% +4.1%

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…fy, new common package tests

Co-authored-by: frjcomp <107982661+frjcomp@users.noreply.github.com>
Copilot AI changed the title [WIP] Analyze test quality and coverage for Go project Improve test quality: table-driven tests, parallel execution, testify assertions, and new common package coverage Mar 3, 2026
@frjcomp frjcomp marked this pull request as ready for review March 3, 2026 14:04
Copilot AI review requested due to automatic review settings March 3, 2026 14:04
Copy link
Contributor

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 improves the quality, isolation, and coverage of the Go test suite for Pipeleek’s CLI and helper packages by strengthening assertions, adding table-driven patterns, and enabling parallel execution where safe.

Changes:

  • Refactors and strengthens CLI command tests using table-driven tests and testify (assert/require) assertions, including default flag value checks.
  • Adds new unit tests for internal/cmd/common to cover previously untested exported helpers and logging behavior.
  • Enables t.Parallel() across multiple pure/isolated tests in pkg/ to improve test runtime and reduce shared-state coupling.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/format/time_test.go Updates ParseISO8601 tests to assert expected time.Time behavior and runs subtests in parallel.
pkg/format/string_test.go Adds parallel execution to string helper tests (including subtests).
pkg/format/path_test.go Runs directory-check tests and subtests in parallel.
pkg/format/format_test.go Adds parallel execution to size/format-related tests and subtests.
pkg/config/validation_test.go Adds parallel execution to validation tests and subtests.
pkg/archive/strings_test.go Adds parallel execution across multiple string-extraction tests and subtests.
internal/cmd/root_test.go Consolidates global log-level tests into a table-driven test and strengthens flag assertions.
internal/cmd/gitlab/jobToken/jobtoken_test.go Converts manual assertions to testify and checks default flag values.
internal/cmd/gitlab/gitlab_test.go Strengthens assertions and checks default values for key flags.
internal/cmd/devops/devops_test.go Strengthens assertions and validates more flag defaults/shorthands.
internal/cmd/common/common_test.go Adds new tests covering internal/cmd/common helpers (logging hooks/writers/flags/pre-run setup).

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…s, renovate, logging

Co-authored-by: frjcomp <107982661+frjcomp@users.noreply.github.com>
Copilot AI changed the title Improve test quality: table-driven tests, parallel execution, testify assertions, and new common package coverage Improve test coverage across weak spots: +5.3pp total coverage Mar 3, 2026
…ConfigFileContents outDir, extract fetchVersionFromHTML, pure deduplicateFindingsWithState

Co-authored-by: frjcomp <107982661+frjcomp@users.noreply.github.com>
Copilot AI changed the title Improve test coverage across weak spots: +5.3pp total coverage Improve test coverage: refactor for testability and add targeted unit tests Mar 3, 2026
…RenovateConfig, ValidateRenovateConfigService, downloadFile; add formatLevelWithHitColor and loadConfigFile tests

Co-authored-by: frjcomp <107982661+frjcomp@users.noreply.github.com>
Copilot AI changed the title Improve test coverage: refactor for testability and add targeted unit tests Round 3: inject HTTP clients for testability; add branch tests for formatLevelWithHitColor, loadConfigFile, downloadFile Mar 3, 2026
…tLogger, SaveTerminalState, setupQueue, GetQueueStatus, analyzeQueueItem, Hit nil-path, setupGlobalHitWriter

Co-authored-by: frjcomp <107982661+frjcomp@users.noreply.github.com>
Copilot AI changed the title Round 3: inject HTTP clients for testability; add branch tests for formatLevelWithHitColor, loadConfigFile, downloadFile Round 4: Boost unit test coverage across docs, common, gitlab/scan, and logging packages Mar 3, 2026
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.

3 participants