github.com/anchore/syft@v1.4.2-0.20240516191711-1bec1fc5d397/syft/pkg/cataloger/python/parse_poetry_lock_test.go (about) 1 package python 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 TestParsePoetryLock(t *testing.T) { 13 fixture := "test-fixtures/poetry/poetry.lock" 14 locations := file.NewLocationSet(file.NewLocation(fixture)) 15 expectedPkgs := []pkg.Package{ 16 { 17 Name: "added-value", 18 Version: "0.14.2", 19 PURL: "pkg:pypi/added-value@0.14.2", 20 Locations: locations, 21 Language: pkg.Python, 22 Type: pkg.PythonPkg, 23 Metadata: pkg.PythonPoetryLockEntry{Index: "https://test.pypi.org/simple"}, 24 }, 25 { 26 Name: "alabaster", 27 Version: "0.7.12", 28 PURL: "pkg:pypi/alabaster@0.7.12", 29 Locations: locations, 30 Language: pkg.Python, 31 Type: pkg.PythonPkg, 32 Metadata: pkg.PythonPoetryLockEntry{Index: "https://pypi.org/simple"}, 33 }, 34 { 35 Name: "appnope", 36 Version: "0.1.0", 37 PURL: "pkg:pypi/appnope@0.1.0", 38 Locations: locations, 39 Language: pkg.Python, 40 Type: pkg.PythonPkg, 41 Metadata: pkg.PythonPoetryLockEntry{Index: "https://pypi.org/simple"}, 42 }, 43 { 44 Name: "asciitree", 45 Version: "0.3.3", 46 PURL: "pkg:pypi/asciitree@0.3.3", 47 Locations: locations, 48 Language: pkg.Python, 49 Type: pkg.PythonPkg, 50 Metadata: pkg.PythonPoetryLockEntry{Index: "https://pypi.org/simple"}, 51 }, 52 } 53 54 // TODO: relationships are not under test 55 var expectedRelationships []artifact.Relationship 56 57 pkgtest.TestFileParser(t, fixture, parsePoetryLock, expectedPkgs, expectedRelationships) 58 }