Skip to content

Commit

Permalink
Update tests to check hasField template func
Browse files Browse the repository at this point in the history
  • Loading branch information
jlehman9 committed Apr 20, 2023
1 parent 1a301b5 commit df49fa9
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 11 deletions.
2 changes: 2 additions & 0 deletions syft/formats/internal/testutils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ func populateImageCatalog(catalog *pkg.Catalog, img *image.Image) {
Metadata: pkg.PythonPackageMetadata{
Name: "package-1",
Version: "1.0.1",
Author: "package-author",
},
PURL: "a-purl-1", // intentionally a bad pURL for test fixtures
CPEs: []cpe.CPE{
Expand Down Expand Up @@ -253,6 +254,7 @@ func newDirectoryCatalog() *pkg.Catalog {
Metadata: pkg.PythonPackageMetadata{
Name: "package-1",
Version: "1.0.1",
Author: "package-author",
Files: []pkg.PythonFileRecord{
{
Path: "/some/path/pkg1/dependencies/foo",
Expand Down
1 change: 1 addition & 0 deletions syft/formats/syftjson/encoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func TestEncodeFullJSONDocument(t *testing.T) {
Metadata: pkg.PythonPackageMetadata{
Name: "package-1",
Version: "1.0.1",
Author: "package-author",
Files: []pkg.PythonFileRecord{},
},
PURL: "a-purl-1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"artifacts": [
{
"id": "1b1d0be59ac59d2c",
"id": "df2ba437ec3dfded",
"name": "package-1",
"version": "1.0.1",
"type": "python",
Expand All @@ -24,7 +24,7 @@
"name": "package-1",
"version": "1.0.1",
"license": "",
"author": "",
"author": "package-author",
"authorEmail": "",
"platform": "",
"files": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"artifacts": [
{
"id": "304a5a8e5958a49d",
"id": "bf332d3aaa83a147",
"name": "package-1",
"version": "1.0.1",
"type": "python",
Expand All @@ -24,7 +24,7 @@
"name": "package-1",
"version": "1.0.1",
"license": "",
"author": "",
"author": "package-author",
"authorEmail": "",
"platform": "",
"sitePackagesRootPath": ""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"artifacts": [
{
"id": "66ba429119b8bec6",
"id": "3b71b371e0f36e18",
"name": "package-1",
"version": "1.0.1",
"type": "python",
Expand All @@ -25,7 +25,7 @@
"name": "package-1",
"version": "1.0.1",
"license": "",
"author": "",
"author": "package-author",
"authorEmail": "",
"platform": "",
"sitePackagesRootPath": ""
Expand Down
4 changes: 2 additions & 2 deletions syft/formats/template/test-fixtures/csv.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"Package","Version Installed", "Found by"
"Package","Version Installed", "Found by", "Author"
{{- range .Artifacts}}
"{{.Name}}","{{.Version}}","{{.FoundBy}}"
"{{.Name}}","{{.Version}}","{{.FoundBy}}","{{ if hasField .Metadata "Author" }}{{ .Metadata.Author }}{{ else }}NO AUTHOR SUPPLIED{{end}}"
{{- end}}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"Package","Version Installed", "Found by"
"package-1","1.0.1","the-cataloger-1"
"package-2","2.0.1","the-cataloger-2"
"Package","Version Installed", "Found by", "Author"
"package-1","1.0.1","the-cataloger-1","package-author"
"package-2","2.0.1","the-cataloger-2","NO AUTHOR SUPPLIED"

0 comments on commit df49fa9

Please sign in to comment.