-
Notifications
You must be signed in to change notification settings - Fork 0
/
output_csv_test.go
43 lines (36 loc) · 930 Bytes
/
output_csv_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
package main
import (
"bytes"
"encoding/csv"
"testing"
"time"
)
func TestCsvOutput(t *testing.T) {
notificationData := NotificationData{}
notificationData.Email = "[email protected]"
images := make(map[string]ImageData)
images["my.domain.com/image:v1"] = ImageData{
Image: "my.domain.com/image:v1",
BuildTimestamp: time.Now().Add(-(time.Hour * 24 * 30)),
Findings: []FindingData{
FindingData{
Namespace: "test",
PodName: "testpod",
NotificationData: ¬ificationData,
},
},
}
result, err := getCsv(&images)
if err != nil {
t.Fatalf("Error not nil when serializing to Json")
}
reader := bytes.NewReader(result)
csvReader := csv.NewReader(reader)
records, err := csvReader.ReadAll()
if err != nil {
t.Fatalf("Error not nil when serializing to Csv")
}
if records[1][3] != "[email protected]" {
t.Fatalf("Output csv does not contain expected entry")
}
}