Skip to content

Add tests for the go-template pull metadata handler #2165

Closed

Description

@TerryHowe

Problem

cmd/oras/internal/display/metadata/template/pull.go has no test coverage. Every method of PullHandler is at 0% of statements:

template/pull.go:38  NewPullHandler   0.0%
template/pull.go:47  OnPulled         0.0%
template/pull.go:52  Render           0.0%
template/pull.go:57  OnFilePulled     0.0%
template/pull.go:62  OnLayerSkipped   0.0%

#2164 added tests for the rest of the template package (attach, discover, manifest fetch, push, repo ls, repo tags) and brought it from 0% to 85.3%. pull.go is the entire remaining gap — covering it would take the package to roughly 100%.

This handler renders the user-facing output of oras pull --format go-template, so a change in its output is immediately visible to users but is currently caught by nothing.

Suggested coverage

Following the style established in #2164 — assert the rendered bytes, not merely that no error came back:

  • Render over a template exercising both the reference and the file list. Note it builds the reference as path + "@" + root.Digest.String() unconditionally, so the digest form is worth pinning.
  • Render with an unparsable template returns an error.
  • Render with no files pulled, i.e. before any OnFilePulled call.
  • OnFilePulled for a file with a title annotation and for one without, plus the error path when descPath cannot be resolved.
  • OnPulled records the root descriptor and ignores the target.
  • OnLayerSkipped is a no-op returning nil.

Related

Activity

  1. added
    test
    on Sep 13, 2026
  2. Soundcreates commented on Sep 14, 2026

    @Soundcreates
    Contributor

    Hi, I’d like to work on this issue. I’ll add focused unit tests for the remaining pull metadata handler paths, keep the change limited to coverage, and open a PR once the tests pass locally. Please let me know if there is any particular behavior you would like covered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    format outputtest

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions