tests: move existing json tests to json/imgs

Signed-off-by: Alfredo Deza <adeza@anchore.com>
This commit is contained in:
Alfredo Deza 2020-07-01 10:35:09 -04:00
parent 7544330bc2
commit 96d86fa214
8 changed files with 6 additions and 5 deletions

View File

@ -2,6 +2,7 @@ package imgs
import ( import (
"encoding/json" "encoding/json"
"fmt"
"io" "io"
"github.com/anchore/imgbom/imgbom/pkg" "github.com/anchore/imgbom/imgbom/pkg"
@ -82,6 +83,7 @@ func (pres *Presenter) Present(output io.Writer) error {
} }
// populate artifacts... // populate artifacts...
// TODO: move this into a common package so that other text presenters can reuse
for p := range pres.catalog.Enumerate() { for p := range pres.catalog.Enumerate() {
art := artifact{ art := artifact{
Name: p.Name, Name: p.Name,
@ -96,12 +98,11 @@ func (pres *Presenter) Present(output io.Writer) error {
var layer int var layer int
if err != nil { if err != nil {
// TODO: test case // TODO: test case
log.Errorf("could not get metadata from catalog (presenter=json): %+v - error: %w", src, err) return fmt.Errorf("could not get metadata from catalog (presenter=json src=%v): %w", src, err)
layer = 0
} else {
layer = int(fileMetadata.Source.Metadata.Index)
} }
layer = int(fileMetadata.Source.Metadata.Index)
srcObj := source{ srcObj := source{
FoundBy: p.FoundBy, FoundBy: p.FoundBy,
Layer: layer, Layer: layer,

View File

@ -1,4 +1,4 @@
package json package imgs
import ( import (
"bytes" "bytes"