forked from vulncheck-oss/sdk
-
Notifications
You must be signed in to change notification settings - Fork 1
/
utils_test.go
54 lines (50 loc) · 1.26 KB
/
utils_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package sdk
import "testing"
func TestFormatCVE(t *testing.T) {
t.Run("cve is formatted correctly", func(t *testing.T) {
tests := []struct {
name string
cve string
expected string
}{
{
name: "cve is already formatted correctly",
cve: "CVE-2024-38077",
expected: "CVE-2024-38077",
},
{
name: "cve is formatted correctly with lowercase",
cve: "cve-2024-38077",
expected: "CVE-2024-38077",
},
{
name: "cve is formatted correctly with mixed case",
cve: "cVe-2024-38077",
expected: "CVE-2024-38077",
},
{
name: "cve is formatted correctly without prefix",
cve: "2024-38077",
expected: "CVE-2024-38077",
},
{
name: "cve is formatted correctly if underscores are used instead of dashes",
cve: "CVE_2024_38077",
expected: "CVE-2024-38077",
},
{
name: "cve is formatted correctly if special characters are used",
cve: "CVE-2024-38077!",
expected: "CVE-2024-38077",
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
formattedCve := FormatCVE(test.cve)
if formattedCve != test.expected {
t.Errorf("expected %s, got %s", test.expected, formattedCve)
}
})
}
})
}