Skip to content

test(imagesrc,apispecs,managedfile): cover the untested helper rules - #329

Merged
0x73746F66 merged 1 commit into
mainfrom
fix/289-imagesrc-apispecs-managedfile-tests
Nov 13, 2026
Merged

0x73746F66 merged 1 commit into
mainfrom
fix/289-imagesrc-apispecs-managedfile-tests

Conversation

@0x73746F66

Copy link
Copy Markdown
Member

Closes #289

What

Stdlib table tests, matching each package's existing style:

  • internal/imagesrc/imagesrc_helpers_test.go: metaFor (tag ref sets Registry/Repository/Tag, digest ref sets ManifestListDigest), parsePlatform (empty -> linux/host arch, linux/arm64, variant, malformed -> error naming the platform), explainRegistryError (UNAUTHORIZED/DENIED/401 -> docker login <registry>, schema 1, plain fetch <ref>), registryOf (valid and invalid refs), Image.Close on nil, without cleanup, and with cleanup once.
  • internal/apispecs/summary_test.go: Discover skips a zero-byte spec, a sparse file over maxSpecBytes and an unparsable openapi.yaml without stopping the walk, and returns path order; Summary singular/plural operation counts; plural/itoa.
  • internal/managedfile/mode_dryrun_test.go: File.Mode (merge wins over structured), ownsContent (host alone, marker alone, neither, both empty), RemoveFile dry runs for structured-with-backup, structured-ours, structured-not-ours, merge strip, merge nothing-to-strip, block-only and block-among-user-content: outcome flags reported, file and backup untouched.

Bug fixed

apispecs.Summary printed , 2 losss for conversion losses: plural appended a bare s to loss. Words ending in s now take es (2 losses). Nothing else in the repository depends on the old spelling.

Verified

go test -cover passes: imagesrc 63.0%, apispecs 92.1%, managedfile 66.2% (from 55.8%, 49.2%, 59.8%). gofmt clean.

@github-actions

Copy link
Copy Markdown
Contributor

Vulnetix config plan

Manager gitops:vulnetix/cli, prune off, plan hash a8bd984f1753c68b180298051dd9e2524ab644d2ebe9e4c7c811ff4126753b5f

Object Action Changes
~ QualityGate/default update (adopt) severity: null -> "high"

0 to create, 1 to update, 0 to delete, 0 unchanged

@0x73746F66 0x73746F66 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reuse review: plural in internal/apispecs is fixed in place ("loss" -> "losses") rather than a second helper added; the tests use the real Summary, managedfile dry-run and imagesrc helpers with t.TempDir(). No changes needed.

@0x73746F66 0x73746F66 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reuse review: no reinvented Vulnetix patterns found. The change stays inside the package it covers, uses stdlib/testify helpers already used by the repo's tests, and adds no new client, auth, config-schema or shared-package duplicate (checked internal/testutils and sibling repos). Rebased onto current main locally: go vet and go test pass for every touched package. The earlier red checks (CodeQL Analyze, Install a release with verified provenance, Lockfile) were GitHub API rate-limit failures, not code failures; this will be re-run on a rebased head before merge.

- imagesrc: metaFor for tag and digest refs, parsePlatform (default,
  arch, variant, malformed), explainRegistryError (auth, schema 1, plain),
  registryOf, and Image.Close on nil and without cleanup.
- apispecs: Discover skips empty, oversized (sparse file) and unparsable
  spec files without stopping the walk and returns path order; Summary
  operation counts; plural and itoa.
- managedfile: File.Mode, ownsContent, and RemoveFile dry runs in every
  mode report the outcome without touching the file or its backup.

The plural case found that Summary printed "2 losss": plural appended a
bare s to "loss". Words ending in s now take es.

Closes #289
@0x73746F66
0x73746F66 force-pushed the fix/289-imagesrc-apispecs-managedfile-tests branch from b67dea2 to d524da0 Compare November 13, 2026 11:25
@0x73746F66
0x73746F66 merged commit 172d76d into main Nov 13, 2026
32 of 33 checks passed
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.

Cover imagesrc metaFor/parsePlatform/explainRegistryError, apispecs skip+summary, managedfile dry-run and Mode

1 participant