MCPcopy Index your code
hub / github.com/dearcode/candy / TestFileDB

Function TestFileDB

store/file_test.go:21–43  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

19}
20
21func TestFileDB(t *testing.T) {
22 dat := []byte("xxxxxxxzzzzzzzzzzzAAAAAAABBBBBBBBB")
23 key := util.MD5(dat)
24 if err := f.add(key, dat); err != nil {
25 t.Fatalf("add key error:%s", err.Error())
26 }
27 ok, err := f.exist(key)
28 if err != nil {
29 t.Fatalf("exist error:%s", err.Error())
30 }
31
32 if !ok {
33 t.Fatalf("expect exists")
34 }
35
36 val, err := f.get(key)
37 if err != nil {
38 t.Fatalf("get key error:%s", err.Error())
39 }
40 if !bytes.Equal(val, dat) {
41 t.Fatalf("src val:%q, get val:%q", dat, val)
42 }
43}

Callers

nothing calls this directly

Calls 4

addMethod · 0.80
ErrorMethod · 0.45
existMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected