Skip to content

test: improve test coverage#367

Open
svietry wants to merge 1 commit into
mainfrom
test-coverage
Open

test: improve test coverage#367
svietry wants to merge 1 commit into
mainfrom
test-coverage

Conversation

@svietry
Copy link
Copy Markdown
Contributor

@svietry svietry commented Feb 23, 2026

Summary

  • Improve unit test coverage from 62.9% → 67.6%, bringing 3 packages to 100% coverage (internal/logger, internal/tracker, pkg/connection)
  • Add 510 lines of new tests across 7 files — 3 new test files and 4 extended existing test files
  • All new tests are pure unit tests with no AWS credentials or external dependencies required

What changed

New test files:

  • pkg/connection/connection_test.go — table-driven tests for AnchoreInfo.IsValid() (6 cases)
  • internal/tracker/time_test.go — tests for TrackFunctionTime
  • pkg/lib_test.go — test for SetLogger

Extended test files:

  • pkg/inventory/report_test.go — TestHandleReport (dry run, valid/invalid anchore, quiet modes) and Test_reportToStdout (JSON output verification)
  • pkg/inventory/ecs_test.go — Test_buildContainerTagMap (empty tasks, @ images, clean tags, mixed, nil digest)
  • pkg/reporter/reporter_test.go — Test_prepareRequest (URL, auth, headers, body) and Test_fetchVersionedAPIPath (v1/v2/error responses)
  • internal/logger/logger_test.go — TestNoOpLoggerMethods and TestZapLoggerMethods covering all wrapper methods (Debug, Debugf, Warn, Warnf, Error, Info)

Test plan

  • go test ./... passes with no failures
  • No changes to production code

@svietry svietry requested a review from a team as a code owner February 23, 2026 14:25
Signed-off-by: Shari Vietry <shari.vietry@gmail.com>
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.

1 participant