Round 4: Boost unit test coverage across docs, common, gitlab/scan, and logging packages#538
Open
Round 4: Boost unit test coverage across docs, common, gitlab/scan, and logging packages#538
Conversation
…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
Contributor
There was a problem hiding this comment.
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/commonto cover previously untested exported helpers and logging behavior. - Enables
t.Parallel()across multiple pure/isolated tests inpkg/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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 eliminated —
pkg/gitlab/renovate/enumhad local copies ofvalidateRenovateConfigServiceandfetchCurrentSelfHostedOptions(each ~20 lines). Replaced with single-line delegations to the shared implementations.Pure functions with untested branches —
validateOrderBy,deduplicateFindingsWithState,formatLevelWithHitColor,fetchVersionFromHTML,dumpConfigFileContentsrefactored 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) andinlineSVGIntoGettingStarted(missing file, no placeholder early-return, missing SVG, full replacement)internal/cmd/common(50% → 70.8%):InitLoggerin console/JSON/no-logfile modes;SaveTerminalState/RestoreTerminalStateno-panic pathspkg/gitlab/scan(22.8% → 32.1%):setupQueue(default tempdir, relative, absolute);GetQueueStatusnil/non-nilglobQueue;analyzeQueueItemunknown-type dispatch and invalid-JSON error pathpkg/logging(62.5% → 68.8%):setupGlobalHitWritervia theHit()nil-writer branch; idempotentsync.Onceconcurrent initCoverage delta across all rounds
pkg/renovateinternal/cmdinternal/cmd/commonpkg/docspkg/gitlab/scanpkg/scanner/rulespkg/logging💡 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.