mirror of
https://github.com/anchore/syft.git
synced 2026-10-30 14:02:26 +01:00
Allow for cataloging a single file (#608)
* allow for cataloging a single file Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * use all catalogers for file schemes Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
@@ -130,6 +130,16 @@ func TestPackagesCmdFlags(t *testing.T) {
|
||||
assertFailingReturnCode, // upload can't go anywhere, so if this passes that would be surprising
|
||||
},
|
||||
},
|
||||
{
|
||||
// we want to make certain that syft can catalog a single go binary and get a SBOM report that is not empty
|
||||
name: "catalog-single-go-binary",
|
||||
args: []string{"packages", "-o", "json", getSyftBinaryLocation(t)},
|
||||
assertions: []traitAssertion{
|
||||
assertJsonReport,
|
||||
assertStdoutLengthGreaterThan(1000),
|
||||
assertSuccessfulReturnCode,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
||||
@@ -75,6 +75,16 @@ func assertInOutput(data string) traitAssertion {
|
||||
}
|
||||
}
|
||||
|
||||
func assertStdoutLengthGreaterThan(length uint) traitAssertion {
|
||||
return func(tb testing.TB, stdout, _ string, _ int) {
|
||||
tb.Helper()
|
||||
if uint(len(stdout)) < length {
|
||||
tb.Errorf("not enough output (expected at least %d, got %d)", length, len(stdout))
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func assertFailingReturnCode(tb testing.TB, _, _ string, rc int) {
|
||||
tb.Helper()
|
||||
if rc == 0 {
|
||||
|
||||
Reference in New Issue
Block a user