syft/test/cli/dir_root_scan_regression_test.go
Jonas Galvão Xavier d3804d1a82
ignore target link files based on path (#667)
* ignore target link files based on path

log when files are actually indexed

add test for sym link resolution

golang test nits

Signed-off-by: Jonas Galvão Xavier <jonas.agx@gmail.com>

* nil catalog should act like an empty catalog

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* remove dir path filtering in favor of file type filtering

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* split out addPathToIndex into specialized functions

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* add test for nul catalog enumeration

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* conditionally discover MIME types for file based on file resolver index

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* change logging around cataloging

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* add tests to cover possible infinite symlink loop for resolver

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

Co-authored-by: Alex Goodman <alex.goodman@anchore.com>
2021-12-13 20:49:11 -05:00

46 lines
890 B
Go

package cli
import (
"os/exec"
"strings"
"testing"
"time"
)
func TestDirectoryScanCompletesWithinTimeout(t *testing.T) {
image := "alpine:latest"
// we want to pull the image ahead of the test as to not affect the timeout value
pullDockerImage(t, image)
var cmd *exec.Cmd
var stdout, stderr string
done := make(chan struct{})
go func() {
defer close(done)
cmd, stdout, stderr = runSyftInDocker(t, nil, image, "dir:/", "-vv")
}()
select {
case <-done:
break
case <-time.After(10 * time.Second):
t.Fatalf("directory scan is taking too long")
}
assertions := []traitAssertion{
assertTableReport,
assertSuccessfulReturnCode,
}
for _, traitFn := range assertions {
traitFn(t, stdout, stderr, cmd.ProcessState.ExitCode())
}
if t.Failed() {
t.Log("STDOUT:\n", stdout)
t.Log("STDERR:\n", stderr)
t.Log("COMMAND:", strings.Join(cmd.Args, " "))
}
}