MCPcopy Create free account
hub / github.com/AdRoll/baker / TestColdCacheGet

Function TestColdCacheGet

pkg/buffercache/cold_test.go:12–39  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestColdCacheGet(t *testing.T) {
13 l0 := []byte("hello")
14 l1 := []byte("world!!")
15 bucket := newBucket(32, 64)
16 i0, ok := bucket.put(l0, false)
17 if !ok {
18 t.Errorf("got full bucket but it shouldn't be")
19 }
20 i1, ok := bucket.put(l1, false)
21 if !ok {
22 t.Errorf("got full bucket but it shouldn't be")
23 }
24 buf, compressed := bucket.get(i0)
25 if !bytes.Equal(buf, l0) {
26 t.Errorf("got bucket.get(%d) = %s, want %s", i0, buf, l0)
27 }
28 if compressed {
29 t.Errorf("got bucket.get(%d) compressed", i0)
30 }
31
32 buf, compressed = bucket.get(i1)
33 if !bytes.Equal(buf, l1) {
34 t.Errorf("got bucket.get(%d) = %s, want %s", i1, buf, l0)
35 }
36 if compressed {
37 t.Errorf("got bucket.get(%d) compressed", i1)
38 }
39}
40
41func TestColdCacheGet_BadCell(t *testing.T) {
42 bucket := newBucket(32, 64)

Callers

nothing calls this directly

Calls 3

newBucketFunction · 0.85
putMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected