Skip to content

[Tech Debt]: Increase cmd/virtwork test coverage from 11% to 80%+ #142

Description

@mrhillsman

Category

Missing tests

Description

cmd/virtwork has only 11% test coverage — the lowest of any package in the project. This package contains the Cobra command wiring, flag parsing, runE, cleanupE, printSummary, printCleanupPreview, PromptForConfirmation, and initAuditor. These are the primary user-facing code paths, and bugs here are the most likely to reach end users.

The orchestrator underneath has 73% coverage, but the Cobra command layer that calls into it is largely untested. Flag validation, --dry-run paths, error formatting, and interactive prompt handling all lack unit tests.

Severity

Medium — increases maintenance burden or risk of future bugs

Affected Files

  • cmd/virtwork/main.gorunE, cleanupE, printSummary, printCleanupPreview, initAuditor, PromptForConfirmation

Proposed Fix

Add Ginkgo BDD tests for:

  • Flag validation and mutual exclusion (e.g. --dry-run vs --yes)
  • --dry-run execution path (no K8s calls, expected output)
  • initAuditor with --no-audit and --audit-db flags
  • printSummary and printCleanupPreview output formatting
  • PromptForConfirmation with simulated stdin
  • Error propagation from runE/cleanupE to the root command

Area

CLI / Configuration, Testing

Architecture Layer

Layer 4 - Orchestration (cmd, cleanup)

Metadata

Metadata

Assignees

No one assigned

    Labels

    tech-debtTechnical debt, code quality, or maintenance concern

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions