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

Function TestFileList_Add

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

Source from the content-addressed store, hash-verified

38}
39
40func TestFileList_Add(t *testing.T) {
41 if !testutils.IsSingleTesting() {
42 return
43 }
44
45 var list = caches.NewSQLiteFileList(Tea.Root + "/data/cache-index/p1").(*caches.SQLiteFileList)
46
47 defer func() {
48 _ = list.Close()
49 }()
50
51 err := list.Init()
52 if err != nil {
53 t.Fatal(err)
54 }
55
56 defer func() {
57 _ = list.Close()
58 }()
59
60 var hash = stringutil.Md5("123456")
61 t.Log("db index:", list.GetDBIndex(hash))
62 err = list.Add(hash, &caches.Item{
63 Key: "123456",
64 ExpiresAt: time.Now().Unix() + 1,
65 HeaderSize: 1,
66 MetaSize: 2,
67 BodySize: 3,
68 Host: "teaos.cn",
69 ServerId: 1,
70 })
71 if err != nil {
72 t.Fatal(err)
73 }
74
75 t.Log(list.Exist(hash))
76
77 t.Log("ok")
78}
79
80func TestFileList_Add_Many(t *testing.T) {
81 if !testutils.IsSingleTesting() {

Callers

nothing calls this directly

Calls 9

IsSingleTestingFunction · 0.92
NewSQLiteFileListFunction · 0.92
LogMethod · 0.80
GetDBIndexMethod · 0.80
UnixMethod · 0.80
CloseMethod · 0.65
InitMethod · 0.65
AddMethod · 0.65
ExistMethod · 0.65

Tested by

no test coverage detected