github.com/noqcks/syft@v0.0.0-20230920222752-a9e2c4e288e5/syft/pkg/cataloger/githubactions/parse_composite_action_test.go (about)

     1  package githubactions
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/anchore/syft/syft/artifact"
     7  	"github.com/anchore/syft/syft/file"
     8  	"github.com/anchore/syft/syft/pkg"
     9  	"github.com/anchore/syft/syft/pkg/cataloger/internal/pkgtest"
    10  )
    11  
    12  func Test_parseCompositeActionForActionUsage(t *testing.T) {
    13  	fixture := "test-fixtures/composite-action.yaml"
    14  	fixtureLocationSet := file.NewLocationSet(file.NewLocation(fixture).WithAnnotation(pkg.EvidenceAnnotationKey, pkg.PrimaryEvidenceAnnotation))
    15  
    16  	expected := []pkg.Package{
    17  		{
    18  			Name:      "actions/setup-go",
    19  			Version:   "v4",
    20  			Type:      pkg.GithubActionPkg,
    21  			Locations: fixtureLocationSet,
    22  			PURL:      "pkg:github/actions/setup-go@v4",
    23  		},
    24  		{
    25  			Name:      "actions/cache",
    26  			Version:   "v3",
    27  			Type:      pkg.GithubActionPkg,
    28  			Locations: fixtureLocationSet,
    29  			PURL:      "pkg:github/actions/cache@v3",
    30  		},
    31  	}
    32  
    33  	var expectedRelationships []artifact.Relationship
    34  	pkgtest.TestFileParser(t, fixture, parseCompositeActionForActionUsage, expected, expectedRelationships)
    35  }