mirror of
https://github.com/anchore/syft.git
synced 2026-11-01 15:06:36 +01:00
use common entry point for integration tests; refactor cmd pkg (#86)
This commit is contained in:
@@ -5,24 +5,25 @@ package integration
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/anchore/go-testutils"
|
||||
"github.com/anchore/imgbom/imgbom"
|
||||
|
||||
"github.com/anchore/go-testutils"
|
||||
"github.com/anchore/imgbom/imgbom/distro"
|
||||
"github.com/anchore/imgbom/imgbom/scope"
|
||||
"github.com/go-test/deep"
|
||||
)
|
||||
|
||||
func TestDistroImage(t *testing.T) {
|
||||
img, cleanup := testutils.GetFixtureImage(t, "docker-archive", "image-distro-id")
|
||||
fixtureImageName := "image-distro-id"
|
||||
_, cleanup := testutils.GetFixtureImage(t, "docker-archive", fixtureImageName)
|
||||
tarPath := testutils.GetFixtureImageTarPath(t, fixtureImageName)
|
||||
defer cleanup()
|
||||
|
||||
s, err := imgbom.GetScopeFromImage(img, scope.AllLayersScope)
|
||||
_, _, actualDistro, err := imgbom.Catalog("docker-archive://"+tarPath, scope.AllLayersScope)
|
||||
if err != nil {
|
||||
t.Fatalf("could not populate scope with image: %+v", err)
|
||||
t.Fatalf("failed to catalog image: %+v", err)
|
||||
}
|
||||
|
||||
actual := imgbom.IdentifyDistro(s)
|
||||
if actual == nil {
|
||||
if actualDistro == nil {
|
||||
t.Fatalf("could not find distro")
|
||||
}
|
||||
|
||||
@@ -31,7 +32,7 @@ func TestDistroImage(t *testing.T) {
|
||||
t.Fatalf("could not create distro: %+v", err)
|
||||
}
|
||||
|
||||
diffs := deep.Equal(*actual, expected)
|
||||
diffs := deep.Equal(*actualDistro, expected)
|
||||
if len(diffs) != 0 {
|
||||
for _, d := range diffs {
|
||||
t.Errorf("found distro difference: %+v", d)
|
||||
|
||||
+7
-6
@@ -5,21 +5,22 @@ package integration
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/anchore/imgbom/imgbom"
|
||||
|
||||
"github.com/anchore/imgbom/internal"
|
||||
|
||||
"github.com/anchore/go-testutils"
|
||||
"github.com/anchore/imgbom/imgbom/cataloger"
|
||||
"github.com/anchore/imgbom/imgbom/pkg"
|
||||
"github.com/anchore/imgbom/imgbom/scope"
|
||||
)
|
||||
|
||||
func TestLanguageImage(t *testing.T) {
|
||||
img, cleanup := testutils.GetFixtureImage(t, "docker-archive", "image-pkg-coverage")
|
||||
func TestPkgCoverageImage(t *testing.T) {
|
||||
fixtureImageName := "image-pkg-coverage"
|
||||
_, cleanup := testutils.GetFixtureImage(t, "docker-archive", fixtureImageName)
|
||||
tarPath := testutils.GetFixtureImageTarPath(t, fixtureImageName)
|
||||
defer cleanup()
|
||||
|
||||
s, err := scope.NewScopeFromImage(img, scope.AllLayersScope)
|
||||
|
||||
catalog, err := cataloger.Catalog(s)
|
||||
catalog, _, _, err := imgbom.Catalog("docker-archive://"+tarPath, scope.AllLayersScope)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to catalog image: %+v", err)
|
||||
}
|
||||
Reference in New Issue
Block a user