github.com/lineaje-labs/syft@v0.98.1-0.20231227153149-9e393f60ff1b/syft/pkg/cataloger/r/cataloger_test.go (about) 1 package r 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/lineaje-labs/syft/syft/pkg/cataloger/internal/pkgtest" 10 ) 11 12 func TestRPackageCataloger(t *testing.T) { 13 expectedPkgs := []pkg.Package{ 14 { 15 Name: "base", 16 Version: "4.3.0", 17 FoundBy: "r-package-cataloger", 18 Locations: file.NewLocationSet(file.NewLocation("base/DESCRIPTION")), 19 Licenses: pkg.NewLicenseSet([]pkg.License{pkg.NewLicense("Part of R 4.3.0")}...), 20 Language: pkg.R, 21 Type: pkg.Rpkg, 22 PURL: "pkg:cran/base@4.3.0", 23 Metadata: pkg.RDescription{ 24 Title: "The R Base Package", 25 Description: "Base R functions.", 26 Author: "R Core Team and contributors worldwide", 27 Maintainer: "R Core Team <do-use-Contact-address@r-project.org>", 28 Built: "R 4.3.0; ; 2023-04-21 11:33:09 UTC; unix", 29 Suggests: []string{"methods"}, 30 }, 31 }, 32 { 33 Name: "stringr", 34 Version: "1.5.0.9000", 35 FoundBy: "r-package-cataloger", 36 Locations: file.NewLocationSet(file.NewLocation("stringr/DESCRIPTION")), 37 Licenses: pkg.NewLicenseSet([]pkg.License{pkg.NewLicense("MIT")}...), 38 Language: pkg.R, 39 Type: pkg.Rpkg, 40 PURL: "pkg:cran/stringr@1.5.0.9000", 41 Metadata: pkg.RDescription{ 42 Title: "Simple, Consistent Wrappers for Common String Operations", 43 Description: "A consistent, simple and easy to use set of wrappers around the fantastic 'stringi' package. All function and argument names (and positions) are consistent, all functions deal with \"NA\"'s and zero length vectors in the same way, and the output from one function is easy to feed into the input of another.", 44 URL: []string{"https://stringr.tidyverse.org", "https://github.com/tidyverse/stringr"}, 45 Imports: []string{ 46 "cli", "glue (>= 1.6.1)", "lifecycle (>= 1.0.3)", "magrittr", 47 "rlang (>= 1.0.0)", "stringi (>= 1.5.3)", "vctrs (>= 0.4.0)", 48 }, 49 Depends: []string{"R (>= 3.3)"}, 50 Suggests: []string{"covr", "dplyr", "gt", "htmltools", "htmlwidgets", "knitr", "rmarkdown", "testthat (>= 3.0.0)", "tibble"}, 51 }, 52 }, 53 } 54 // TODO: relationships are not under test yet 55 var expectedRelationships []artifact.Relationship 56 57 pkgtest.NewCatalogTester().FromDirectory(t, "test-fixtures/installed").Expects(expectedPkgs, expectedRelationships).TestCataloger(t, NewPackageCataloger()) 58 }