@@ -10,21 +10,15 @@ import (
1010"github.com/stretchr/testify/require"
1111)
1212
13- func TestIsSnykID (t * testing.T ) {
13+ func TestStartsWithSnyk (t * testing.T ) {
1414tests := []struct {
1515name string
1616id string
1717expected bool
1818}{
1919// Valid Snyk IDs
20- {"uppercase with hyphen" ,"SNYK-JS-LODASH-590103" ,true },
21- {"lowercase with hyphen" ,"snyk-js-lodash-590103" ,true },
22- {"mixed case with hyphen" ,"Snyk-JS-LODASH-590103" ,true },
23- {"uppercase with colon" ,"SNYK:LIC:NPM:PACKAGE:MPL-2.0" ,true },
24- {"lowercase with colon" ,"snyk:lic:npm:shescape:MPL-2.0" ,true },
25- {"mixed case with colon" ,"Snyk:lic:npm:package:MIT" ,true },
26- {"just snyk" ,"snyk" ,true },
27- {"snyk with no delimiter" ,"snyktest" ,true },
20+ {"vuln" ,"snyk_vuln" ,true },
21+ {"license" ,"snyk_license" ,true },
2822
2923// Invalid/non-Snyk IDs
3024{"CVE" ,"CVE-2021-1234" ,false },
@@ -38,16 +32,16 @@ func TestIsSnykID(t *testing.T) {
3832
3933for _ ,tt := range tests {
4034t .Run (tt .name ,func (t * testing.T ) {
41- result := isSnykID (tt .id )
42- assert .Equal (t ,tt .expected ,result ,"isSnykID (%q) = %v, want %v" ,tt .id ,result ,tt .expected )
35+ result := startsWithSnyk (tt .id )
36+ assert .Equal (t ,tt .expected ,result ,"startsWithSnyk (%q) = %v, want %v" ,tt .id ,result ,tt .expected )
4337})
4438}
4539}
4640
4741func TestIdBasedIssueGrouper_ExtractProblemID (t * testing.T ) {
4842grouper := & idBasedIssueGrouper {}
4943
50- t .Run ("prefersSNYK- ID over CVE" ,func (t * testing.T ) {
44+ t .Run ("prefersSNYK_ ID over CVE" ,func (t * testing.T ) {
5145finding := & FindingData {
5246Attributes :& FindingAttributes {
5347FindingType :FindingTypeSca ,
@@ -115,13 +109,13 @@ func TestIdBasedIssueGrouper_ExtractProblemID(t *testing.T) {
115109FindingType :FindingTypeSca ,
116110Problems : []Problem {
117111createProblem (t ,"CVE-2021-1234" ,"cve" ),
118- createProblem (t ,"Snyk -JS-LODASH-590103" ,"snyk_vuln" ),
112+ createProblem (t ,"SNYK -JS-LODASH-590103" ,"snyk_vuln" ),
119113},
120114},
121115}
122116
123117id := grouper .extractProblemID (finding )
124- assert .Equal (t ,"Snyk -JS-LODASH-590103" ,id )
118+ assert .Equal (t ,"SNYK -JS-LODASH-590103" ,id )
125119})
126120
127121t .Run ("returns empty string when no problems" ,func (t * testing.T ) {