mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 08:23:15 +01:00
* split up sbom.Format into encode and decode ops Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * update cmd pkg to inject format configs Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * bump cyclonedx schema to 1.5 Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * redact image metadata from github encoder tests Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add more testing around format decoder identify Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add test case for format version options Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix cli tests Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix CLI test Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * [wip] - review comments Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * keep encoder creation out of post load function Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * keep decider and identify functions Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add a few more doc comments Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * remove format encoder default function helpers Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * address PR feedback Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * move back to streaming based decode functions Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * with common convention for encoder constructors Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix tests and allow for encoders to be created from cli options Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix cli tests Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix linting Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * buffer reads from stdin to support seeking Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> --------- Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
58 lines
1.1 KiB
Go
58 lines
1.1 KiB
Go
package spdxhelpers
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/anchore/syft/syft/pkg"
|
|
)
|
|
|
|
func Test_Homepage(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
input pkg.Package
|
|
expected string
|
|
}{
|
|
{
|
|
// note: since this is an optional field, no value is preferred over NONE or NOASSERTION
|
|
name: "no metadata",
|
|
input: pkg.Package{},
|
|
expected: "",
|
|
},
|
|
{
|
|
name: "from gem",
|
|
input: pkg.Package{
|
|
Metadata: pkg.GemMetadata{
|
|
Homepage: "http://a-place.gov",
|
|
},
|
|
},
|
|
expected: "http://a-place.gov",
|
|
},
|
|
{
|
|
name: "from npm",
|
|
input: pkg.Package{
|
|
Metadata: pkg.NpmPackageJSONMetadata{
|
|
Homepage: "http://a-place.gov",
|
|
},
|
|
},
|
|
expected: "http://a-place.gov",
|
|
},
|
|
{
|
|
// note: since this is an optional field, no value is preferred over NONE or NOASSERTION
|
|
name: "empty",
|
|
input: pkg.Package{
|
|
Metadata: pkg.NpmPackageJSONMetadata{
|
|
Homepage: "",
|
|
},
|
|
},
|
|
expected: "",
|
|
},
|
|
}
|
|
for _, test := range tests {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
assert.Equal(t, test.expected, Homepage(test.input))
|
|
})
|
|
}
|
|
}
|