pull in temp dir generator from stereoscope

Signed-off-by: Alex Goodman <wagoodman@gmail.com>
This commit is contained in:
Alex Goodman
2021-06-26 23:40:40 -04:00
parent c5390264b0
commit aac0dac0de
13 changed files with 77 additions and 42 deletions
+4 -1
View File
@@ -1,6 +1,7 @@
package integration
import (
"github.com/stretchr/testify/assert"
"testing"
"github.com/anchore/syft/syft/distro"
@@ -24,7 +25,9 @@ func BenchmarkImagePackageCatalogers(b *testing.B) {
for _, c := range cataloger.ImageCatalogers() {
// in case of future alteration where state is persisted, assume no dependency is safe to reuse
theSource, cleanupSource, err := source.New("docker-archive:"+tarPath, nil)
b.Cleanup(cleanupSource)
b.Cleanup(func() {
assert.NoError(b, cleanupSource())
})
if err != nil {
b.Fatalf("unable to get source: %+v", err)
}
+7 -2
View File
@@ -1,6 +1,7 @@
package integration
import (
"github.com/stretchr/testify/assert"
"testing"
"github.com/anchore/stereoscope/pkg/imagetest"
@@ -15,7 +16,9 @@ func catalogFixtureImage(t *testing.T, fixtureImageName string) (*pkg.Catalog, *
tarPath := imagetest.GetFixtureImageTarPath(t, fixtureImageName)
theSource, cleanupSource, err := source.New("docker-archive:"+tarPath, nil)
t.Cleanup(cleanupSource)
t.Cleanup(func() {
assert.NoError(t, cleanupSource())
})
if err != nil {
t.Fatalf("unable to get source: %+v", err)
}
@@ -30,7 +33,9 @@ func catalogFixtureImage(t *testing.T, fixtureImageName string) (*pkg.Catalog, *
func catalogDirectory(t *testing.T, dir string) (*pkg.Catalog, *distro.Distro, source.Source) {
theSource, cleanupSource, err := source.New("dir:"+dir, nil)
t.Cleanup(cleanupSource)
t.Cleanup(func() {
assert.NoError(t, cleanupSource())
})
if err != nil {
t.Fatalf("unable to get source: %+v", err)
}