(t *testing.T)
| 38 | } |
| 39 | |
| 40 | func 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 | |
| 80 | func TestFileList_Add_Many(t *testing.T) { |
| 81 | if !testutils.IsSingleTesting() { |
nothing calls this directly
no test coverage detected