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

     1  package dart
     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 TestParsePubspecLock(t *testing.T) {
    13  	fixture := "test-fixtures/pubspec.lock"
    14  	fixtureLocationSet := file.NewLocationSet(file.NewLocation(fixture))
    15  	expected := []pkg.Package{
    16  		{
    17  			Name:      "ale",
    18  			Version:   "3.3.0",
    19  			PURL:      "pkg:pub/ale@3.3.0?hosted_url=pub.hosted.org",
    20  			Locations: fixtureLocationSet,
    21  			Language:  pkg.Dart,
    22  			Type:      pkg.DartPubPkg,
    23  			Metadata: pkg.DartPubspecLockEntry{
    24  				Name:      "ale",
    25  				Version:   "3.3.0",
    26  				HostedURL: "pub.hosted.org",
    27  			},
    28  		},
    29  		{
    30  			Name:      "analyzer",
    31  			Version:   "0.40.7",
    32  			PURL:      "pkg:pub/analyzer@0.40.7",
    33  			Locations: fixtureLocationSet,
    34  			Language:  pkg.Dart,
    35  			Type:      pkg.DartPubPkg,
    36  			Metadata: pkg.DartPubspecLockEntry{
    37  				Name:    "analyzer",
    38  				Version: "0.40.7",
    39  			},
    40  		},
    41  		{
    42  			Name:      "ansicolor",
    43  			Version:   "1.1.1",
    44  			PURL:      "pkg:pub/ansicolor@1.1.1",
    45  			Locations: fixtureLocationSet,
    46  			Language:  pkg.Dart,
    47  			Type:      pkg.DartPubPkg,
    48  			Metadata: pkg.DartPubspecLockEntry{
    49  				Name:    "ansicolor",
    50  				Version: "1.1.1",
    51  			},
    52  		},
    53  		{
    54  			Name:      "archive",
    55  			Version:   "2.0.13",
    56  			PURL:      "pkg:pub/archive@2.0.13",
    57  			Locations: fixtureLocationSet,
    58  			Language:  pkg.Dart,
    59  			Type:      pkg.DartPubPkg,
    60  			Metadata: pkg.DartPubspecLockEntry{
    61  				Name:    "archive",
    62  				Version: "2.0.13",
    63  			},
    64  		},
    65  		{
    66  			Name:      "args",
    67  			Version:   "1.6.0",
    68  			PURL:      "pkg:pub/args@1.6.0",
    69  			Locations: fixtureLocationSet,
    70  			Language:  pkg.Dart,
    71  			Type:      pkg.DartPubPkg,
    72  			Metadata: pkg.DartPubspecLockEntry{
    73  				Name:    "args",
    74  				Version: "1.6.0",
    75  			},
    76  		},
    77  		{
    78  			Name:      "flutter",
    79  			Version:   "0.0.0",
    80  			PURL:      "pkg:pub/flutter@0.0.0",
    81  			Locations: fixtureLocationSet,
    82  			Language:  pkg.Dart,
    83  			Type:      pkg.DartPubPkg,
    84  			Metadata: pkg.DartPubspecLockEntry{
    85  				Name:    "flutter",
    86  				Version: "0.0.0",
    87  			},
    88  		},
    89  		{
    90  			Name:      "key_binder",
    91  			Version:   "1.11.20",
    92  			PURL:      "pkg:pub/key_binder@1.11.20?vcs_url=git%40github.com:Workiva/key_binder.git%403f7b3a6350e73c7dcac45301c0e18fbd42af02f7",
    93  			Locations: fixtureLocationSet,
    94  			Language:  pkg.Dart,
    95  			Type:      pkg.DartPubPkg,
    96  			Metadata: pkg.DartPubspecLockEntry{
    97  				Name:    "key_binder",
    98  				Version: "1.11.20",
    99  				VcsURL:  "git@github.com:Workiva/key_binder.git@3f7b3a6350e73c7dcac45301c0e18fbd42af02f7",
   100  			},
   101  		},
   102  	}
   103  
   104  	// TODO: relationships are not under test
   105  	var expectedRelationships []artifact.Relationship
   106  
   107  	pkgtest.TestFileParser(t, fixture, parsePubspecLock, expected, expectedRelationships)
   108  }