Skip to content

Increase behavioral test coverage to 70-80% #19

Description

@timimsms

Context

PR #16 brought test coverage from 16% to 51% by cherry-picking testing infrastructure from the coverage audit. The next step is reaching 70-80% with behavioral tests — tests that verify correct behavior, not just code execution.

Current coverage by package

Package Coverage Target
api 24.4% 60%+
auth 0% 70%+
auth/mock 79.7%
cache 35.1% 70%+
cmd 18.8% 40%+
config 69.5% 80%+
errors 89.7%
output 79.6%
version 100%

Approach

The testing infrastructure from PR #16 provides the foundation:

  • Mock infrastructure (internal/auth/mock/, internal/mocks/)
  • Interface definitions (internal/interfaces/)
  • Test utilities (internal/testutil/)

Priority areas

  1. auth package — currently 0%, needs mock keyring tests for save/get/delete token flows
  2. api package — needs tests for API call methods using mock HTTP transport
  3. cache package — needs behavioral tests for TTL, expiration, concurrent access
  4. cmd package — focus on helper function tests (already started), avoid testing Cobra wiring

Quality guidelines

  • Tests should verify behavior, not struct fields
  • Each test should be able to catch a real bug
  • Prefer fewer meaningful tests over many superficial ones
  • Use the auth mock package as the quality template

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions