syft/integration/fixture_image_distro_test.go
Alfredo Deza 429c28720c integration: update tests to use scope instead of img directly
Signed-off-by: Alfredo Deza <adeza@anchore.com>
2020-07-15 07:53:28 -04:00

42 lines
906 B
Go

// +build integration
package integration
import (
"testing"
"github.com/anchore/go-testutils"
"github.com/anchore/imgbom/imgbom"
"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")
defer cleanup()
s, err := imgbom.GetScopeFromImage(img, scope.AllLayersScope)
if err != nil {
t.Fatalf("could not populate scope with image: %+v", err)
}
actual := imgbom.IdentifyDistro(s)
if actual == nil {
t.Fatalf("could not find distro")
}
expected, err := distro.NewDistro(distro.Busybox, "1.31.1")
if err != nil {
t.Fatalf("could not create distro: %+v", err)
}
diffs := deep.Equal(*actual, expected)
if len(diffs) != 0 {
for _, d := range diffs {
t.Errorf("found distro difference: %+v", d)
}
}
}