mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
* add template output Signed-off-by: Jonas Xavier <jonasx@anchore.com> * remove dead code Signed-off-by: Jonas Xavier <jonasx@anchore.com> * fix template cli flag Signed-off-by: Jonas Xavier <jonasx@anchore.com> * implement template's own format type Signed-off-by: Jonas Xavier <jonasx@anchore.com> * simpler code Signed-off-by: Jonas Xavier <jonasx@anchore.com> * fix readme link to Go template Signed-off-by: Jonas Xavier <jonasx@anchore.com> * feedback changes Signed-off-by: Jonas Xavier <jonasx@anchore.com> * simpler func signature patter Signed-off-by: Jonas Xavier <jonasx@anchore.com> * nit Signed-off-by: Jonas Xavier <jonasx@anchore.com> * fix linter error Signed-off-by: Jonas Xavier <jonasx@anchore.com>
30 lines
662 B
Go
30 lines
662 B
Go
package template
|
|
|
|
import (
|
|
"flag"
|
|
"testing"
|
|
|
|
"github.com/anchore/syft/internal/formats/common/testutils"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
var updateTmpl = flag.Bool("update-tmpl", false, "update the *.golden files for json encoders")
|
|
|
|
func TestFormatWithOption(t *testing.T) {
|
|
f := OutputFormat{}
|
|
f.SetTemplatePath("test-fixtures/csv.template")
|
|
|
|
testutils.AssertEncoderAgainstGoldenSnapshot(t,
|
|
f,
|
|
testutils.DirectoryInput(t),
|
|
*updateTmpl,
|
|
)
|
|
|
|
}
|
|
|
|
func TestFormatWithoutOptions(t *testing.T) {
|
|
f := Format()
|
|
err := f.Encode(nil, testutils.DirectoryInput(t))
|
|
assert.ErrorContains(t, err, "no template file: please provide a template path")
|
|
}
|