aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrandon Lum <lumjjb@gmail.com>2022-09-28 09:32:46 -0400
committerGitHub <noreply@github.com>2022-09-28 09:32:46 -0400
commit97ef16cfc20c7ff192156fdebfc21401b360a965 (patch)
tree072c85fa4e94bc4007dcf1fc125b060e8cffe946
parent5eb9315c0c55cd107481fb259b85e4f223d2fb19 (diff)
parent9b78ab0ad01e4469df9e7106b169237e8f2650f5 (diff)
downloadspdx-tools-97ef16cfc20c7ff192156fdebfc21401b360a965.tar.gz
Merge pull request #162 from pxp928/add-enums
added referenceType enum
-rw-r--r--spdx/common/external.go9
-rw-r--r--tvloader/parser2v1/parse_package_test.go6
2 files changed, 12 insertions, 3 deletions
diff --git a/spdx/common/external.go b/spdx/common/external.go
new file mode 100644
index 0000000..b4d84a2
--- /dev/null
+++ b/spdx/common/external.go
@@ -0,0 +1,9 @@
+// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
+
+package common
+
+// *Type is the enumerable of ReferenceType
+const (
+ Cpe23Type string = "cpe23Type"
+ PurlType string = "purl"
+)
diff --git a/tvloader/parser2v1/parse_package_test.go b/tvloader/parser2v1/parse_package_test.go
index 7189ba3..dea9dc4 100644
--- a/tvloader/parser2v1/parse_package_test.go
+++ b/tvloader/parser2v1/parse_package_test.go
@@ -477,7 +477,7 @@ func TestParser2_1CanParsePackageTags(t *testing.T) {
// Package External References and Comments
ref1 := "SECURITY cpe23Type cpe:2.3:a:pivotal_software:spring_framework:4.1.0:*:*:*:*:*:*:*"
ref1Category := "SECURITY"
- ref1Type := "cpe23Type"
+ ref1Type := common.Cpe23Type
ref1Locator := "cpe:2.3:a:pivotal_software:spring_framework:4.1.0:*:*:*:*:*:*:*"
ref1Comment := "this is comment #1"
ref2 := "OTHER LocationRef-acmeforge acmecorp/acmenator/4.1.3alpha"
@@ -1025,7 +1025,7 @@ func TestCanCheckAndExtractExcludesFilenameAndCode(t *testing.T) {
func TestCanExtractPackageExternalReference(t *testing.T) {
ref1 := "SECURITY cpe23Type cpe:2.3:a:pivotal_software:spring_framework:4.1.0:*:*:*:*:*:*:*"
category := "SECURITY"
- refType := "cpe23Type"
+ refType := common.Cpe23Type
location := "cpe:2.3:a:pivotal_software:spring_framework:4.1.0:*:*:*:*:*:*:*"
gotCategory, gotRefType, gotLocation, err := extractPackageExternalReference(ref1)
@@ -1046,7 +1046,7 @@ func TestCanExtractPackageExternalReference(t *testing.T) {
func TestCanExtractPackageExternalReferenceWithExtraWhitespace(t *testing.T) {
ref1 := " SECURITY \t cpe23Type cpe:2.3:a:pivotal_software:spring_framework:4.1.0:*:*:*:*:*:*:* \t "
category := "SECURITY"
- refType := "cpe23Type"
+ refType := common.Cpe23Type
location := "cpe:2.3:a:pivotal_software:spring_framework:4.1.0:*:*:*:*:*:*:*"
gotCategory, gotRefType, gotLocation, err := extractPackageExternalReference(ref1)