-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathscan_test.go
54 lines (44 loc) · 998 Bytes
/
scan_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 main
import (
"fmt"
"io/ioutil"
"log"
"strings"
"testing"
)
func parse(output string, path string) ResultsData {
avg := ResultsData{
Infected: false,
Engine: "test",
}
colonSeparated := []string{}
lines := strings.Split(output, "\n")
// Extract Virus string and extract colon separated lines into an slice
for _, line := range lines {
if len(line) != 0 {
if strings.Contains(line, ":") {
colonSeparated = append(colonSeparated, line)
}
if strings.Contains(line, path) {
pathVirusString := strings.Split(line, " ")
avg.Result = strings.TrimSpace(pathVirusString[1])
}
}
}
return avg
}
// TestParseResult tests the ParseAVGOutput function.
func TestParseResult(t *testing.T) {
r, err := ioutil.ReadFile("tests/av_scan.out")
if err != nil {
fmt.Print(err)
}
results := parse(string(r), "/malware/EICAR")
if err != nil {
log.Fatal(err)
}
if true {
t.Log("Result: ", results.Result)
t.Log("Engine: ", results.Engine)
}
}