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

     1  package golang
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/anchore/syft/syft/pkg/cataloger/internal/pkgtest"
     7  )
     8  
     9  func Test_Mod_Cataloger_Globs(t *testing.T) {
    10  	tests := []struct {
    11  		name     string
    12  		fixture  string
    13  		expected []string
    14  	}{
    15  		{
    16  			name:    "obtain go.mod files",
    17  			fixture: "test-fixtures/glob-paths",
    18  			expected: []string{
    19  				"src/go.mod",
    20  			},
    21  		},
    22  	}
    23  
    24  	for _, test := range tests {
    25  		t.Run(test.name, func(t *testing.T) {
    26  			pkgtest.NewCatalogTester().
    27  				FromDirectory(t, test.fixture).
    28  				ExpectsResolverContentQueries(test.expected).
    29  				IgnoreUnfulfilledPathResponses("src/go.sum").
    30  				TestCataloger(t, NewGoModFileCataloger(GoCatalogerOpts{}))
    31  		})
    32  	}
    33  }
    34  
    35  func Test_Binary_Cataloger_Globs(t *testing.T) {
    36  	tests := []struct {
    37  		name     string
    38  		fixture  string
    39  		expected []string
    40  	}{
    41  		{
    42  			name:    "obtain binary files",
    43  			fixture: "test-fixtures/glob-paths",
    44  			expected: []string{
    45  				"partial-binary",
    46  			},
    47  		},
    48  	}
    49  
    50  	for _, test := range tests {
    51  		t.Run(test.name, func(t *testing.T) {
    52  			pkgtest.NewCatalogTester().
    53  				FromDirectory(t, test.fixture).
    54  				ExpectsResolverContentQueries(test.expected).
    55  				TestCataloger(t, NewGoModuleBinaryCataloger(GoCatalogerOpts{}))
    56  		})
    57  	}
    58  }