syft/test/cli/dir_root_scan_regression_test.go
Keith Zantow 6c3755fbbe
chore: attempt to avoid full snapshot build
Signed-off-by: Keith Zantow <kzantow@gmail.com>
2023-10-13 09:13:01 -04:00

45 lines
931 B
Go

package cli
import (
"os/exec"
"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)
// run once in case we need to rebuild syft binary, so it doesn't affect the timeout value
runSyftInDocker(t, nil, image, "--help")
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())
}
logOutputOnFailure(t, cmd, stdout, stderr)
}