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:
Alex Goodman
2021-11-02 12:09:06 -04:00
committed by GitHub
parent a2882ee810
commit 3ac95ac4f6
8 changed files with 199 additions and 54 deletions
+10
View File
@@ -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 {
+10
View File
@@ -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 {