github.com/anchore/syft@v1.4.2-0.20240516191711-1bec1fc5d397/syft/pkg/cataloger/php/cataloger_test.go (about)

     1  package php
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/anchore/syft/syft/pkg/cataloger/internal/pkgtest"
     7  )
     8  
     9  func Test_ComposerInstalledCataloger_Globs(t *testing.T) {
    10  	tests := []struct {
    11  		name     string
    12  		fixture  string
    13  		expected []string
    14  	}{
    15  		{
    16  			name:    "obtain composer files",
    17  			fixture: "test-fixtures/glob-paths",
    18  			expected: []string{
    19  				"src/installed.json",
    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  				TestCataloger(t, NewComposerInstalledCataloger())
    30  		})
    31  	}
    32  }
    33  
    34  func Test_ComposerLockCataloger_Globs(t *testing.T) {
    35  	tests := []struct {
    36  		name     string
    37  		fixture  string
    38  		expected []string
    39  	}{
    40  		{
    41  			name:    "obtain composer lock files",
    42  			fixture: "test-fixtures/glob-paths",
    43  			expected: []string{
    44  				"src/composer.lock",
    45  			},
    46  		},
    47  	}
    48  
    49  	for _, test := range tests {
    50  		t.Run(test.name, func(t *testing.T) {
    51  			pkgtest.NewCatalogTester().
    52  				FromDirectory(t, test.fixture).
    53  				ExpectsResolverContentQueries(test.expected).
    54  				TestCataloger(t, NewComposerLockCataloger())
    55  		})
    56  	}
    57  }
    58  
    59  func Test_PeclCataloger_Globs(t *testing.T) {
    60  	tests := []struct {
    61  		name     string
    62  		fixture  string
    63  		expected []string
    64  	}{
    65  		{
    66  			name:    "obtain pecl files",
    67  			fixture: "test-fixtures/glob-paths",
    68  			expected: []string{
    69  				"php/.registry/.channel.pecl.php.net/memcached.reg",
    70  			},
    71  		},
    72  	}
    73  
    74  	for _, test := range tests {
    75  		t.Run(test.name, func(t *testing.T) {
    76  			pkgtest.NewCatalogTester().
    77  				FromDirectory(t, test.fixture).
    78  				ExpectsResolverContentQueries(test.expected).
    79  				TestCataloger(t, NewPeclCataloger())
    80  		})
    81  	}
    82  }