MCPcopy
hub / github.com/Tencent/CodeAnalysis / TestScanner

Function TestScanner

tools/owl/scan/scanner_test.go:82–117  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

80}
81
82func TestScanner(t *testing.T) {
83 scanner := new(scan.Scanner)
84 scanner.SetPath("./")
85 res, err := scanner.List()
86 if err != nil {
87 t.Fatal(err)
88 }
89 t.Log(res)
90
91 scanner.SetMatcher(new(scan.Md5Matcher))
92 res, err = scanner.Search("xxxx")
93 if err != nil {
94 t.Fatal(err)
95 }
96 if len(res) != 0 {
97 t.Fatal(res)
98 }
99
100 scanner.SetPath("scanner_test.go")
101 assert.Equal(t, func() string {
102 str, _ := scanner.HexDump()
103 return str
104 }(), func() string {
105 str, _ := scanner.HexDump()
106 return str
107 }())
108
109 file, err := os.OpenFile("res.json", os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0666)
110 if err != nil {
111 t.Fatal(err)
112 }
113 if err := scanner.Output(file, res); err != nil {
114 t.Fatal(err)
115 }
116 os.Remove("res.json")
117}

Callers

nothing calls this directly

Calls 6

SetPathMethod · 0.80
ListMethod · 0.80
SetMatcherMethod · 0.80
HexDumpMethod · 0.80
OutputMethod · 0.80
SearchMethod · 0.65

Tested by

no test coverage detected