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

     1  package githubactions
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/anchore/syft/syft/pkg/cataloger/generic"
     7  	"github.com/anchore/syft/syft/pkg/cataloger/internal/pkgtest"
     8  )
     9  
    10  func TestCataloger_Globs(t *testing.T) {
    11  	tests := []struct {
    12  		name      string
    13  		fixture   string
    14  		cataloger *generic.Cataloger
    15  		expected  []string
    16  	}{
    17  		{
    18  			name:      "obtain all workflow and composite action files",
    19  			fixture:   "test-fixtures/glob",
    20  			cataloger: NewActionUsageCataloger(),
    21  			expected: []string{
    22  				// composite actions
    23  				".github/actions/bootstrap/action.yaml",
    24  				".github/actions/unbootstrap/action.yml",
    25  				// workflows
    26  				".github/workflows/release.yml",
    27  				".github/workflows/validations.yaml",
    28  			},
    29  		},
    30  		{
    31  			name:      "obtain all workflow files",
    32  			fixture:   "test-fixtures/glob",
    33  			cataloger: NewWorkflowUsageCataloger(),
    34  			expected: []string{
    35  				// workflows
    36  				".github/workflows/release.yml",
    37  				".github/workflows/validations.yaml",
    38  			},
    39  		},
    40  	}
    41  
    42  	for _, test := range tests {
    43  		t.Run(test.name, func(t *testing.T) {
    44  			pkgtest.NewCatalogTester().
    45  				FromDirectory(t, test.fixture).
    46  				ExpectsResolverContentQueries(test.expected).
    47  				TestCataloger(t, test.cataloger)
    48  		})
    49  	}
    50  }