MCPcopy
hub / github.com/perkeep/perkeep / TestCache

Function TestCache

pkg/blobserver/memory/mem_test.go:45–63  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

43}
44
45func TestCache(t *testing.T) {
46 c := memory.NewCache(1024)
47 (&test.Blob{Contents: "foo"}).MustUpload(t, c)
48 if got, want := c.SumBlobSize(), int64(3); got != want {
49 t.Errorf("size = %d; want %d", got, want)
50 }
51 (&test.Blob{Contents: "bar"}).MustUpload(t, c)
52 if got, want := c.SumBlobSize(), int64(6); got != want {
53 t.Errorf("size = %d; want %d", got, want)
54 }
55 (&test.Blob{Contents: strings.Repeat("x", 1020)}).MustUpload(t, c)
56 if got, want := c.SumBlobSize(), int64(1023); got != want {
57 t.Errorf("size = %d; want %d", got, want)
58 }
59 (&test.Blob{Contents: "five!"}).MustUpload(t, c)
60 if got, want := c.SumBlobSize(), int64(5); got != want {
61 t.Errorf("size = %d; want %d", got, want)
62 }
63}

Callers

nothing calls this directly

Calls 3

NewCacheFunction · 0.92
MustUploadMethod · 0.80
SumBlobSizeMethod · 0.45

Tested by

no test coverage detected