MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / TestFileList_Exist

Function TestFileList_Exist

internal/caches/list_file_sqlite_test.go:119–157  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

117}
118
119func TestFileList_Exist(t *testing.T) {
120 if !testutils.IsSingleTesting() {
121 return
122 }
123
124 var list = caches.NewSQLiteFileList(Tea.Root + "/data/cache-index/p1").(*caches.SQLiteFileList)
125 defer func() {
126 _ = list.Close()
127 }()
128
129 err := list.Init()
130 if err != nil {
131 t.Fatal(err)
132 }
133
134 total, _ := list.Count()
135 t.Log("total:", total)
136
137 var before = time.Now()
138 defer func() {
139 t.Log(time.Since(before).Seconds()*1000, "ms")
140 }()
141 {
142 var hash = stringutil.Md5("123456")
143 exists, _, err := list.Exist(hash)
144 if err != nil {
145 t.Fatal(err)
146 }
147 t.Log(hash, "exists:", exists)
148 }
149 {
150 var hash = stringutil.Md5("http://edge.teaos.cn/1234561")
151 exists, _, err := list.Exist(hash)
152 if err != nil {
153 t.Fatal(err)
154 }
155 t.Log(hash, "exists:", exists)
156 }
157}
158
159func TestFileList_Exist_Many_DB(t *testing.T) {
160 if !testutils.IsSingleTesting() {

Callers

nothing calls this directly

Calls 7

IsSingleTestingFunction · 0.92
NewSQLiteFileListFunction · 0.92
LogMethod · 0.80
CloseMethod · 0.65
InitMethod · 0.65
CountMethod · 0.65
ExistMethod · 0.65

Tested by

no test coverage detected