forked from snyk-tech-services/jira-tickets-for-new-vulns
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathformatTicket_test.go
44 lines (33 loc) · 892 Bytes
/
formatTicket_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
package main
import (
"bufio"
"fmt"
"log"
"os"
"strings"
"testing"
"github.com/michael-go/go-jsn/jsn"
"github.com/stretchr/testify/assert"
)
func TestFormatJiraTicketFunc(t *testing.T) {
projectInfo, _ := jsn.NewJson(readFixture("./fixtures/project.json"))
issueData, _ := jsn.NewJson(readFixture("./fixtures/vulnForJiraAggregatedWithPathForTicketTest.json"))
flags := flags{}
flags.optionalFlags.cveInTitle = true
jiraTicket := formatJiraTicket(issueData, projectInfo, flags)
// Convert jira ticket into a string
ticket := fmt.Sprintf("%v", jiraTicket)
file, err := os.Open("./fixtures/ticket.txt")
if err != nil {
log.Fatal(err)
}
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
compare := strings.Contains(ticket, scanner.Text())
assert.Equal(t, compare, true)
}
if err := scanner.Err(); err != nil {
log.Fatal(err)
}
}