MCPcopy Index your code
hub / github.com/perkeep/perkeep / TestEviction

Function TestEviction

pkg/blobserver/proxycache/proxycache_test.go:74–102  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

72}
73
74func TestEviction(t *testing.T) {
75 const blobsize = cacheSize / 6
76 px, ds := NewProxiedDisk(t)
77 defer cleanUp(ds)
78
79 tb := test.RandomBlob(t, blobsize)
80 tb.MustUpload(t, px)
81 test.RandomBlob(t, blobsize).MustUpload(t, px)
82 test.RandomBlob(t, blobsize).MustUpload(t, px)
83 test.RandomBlob(t, blobsize).MustUpload(t, px)
84 test.RandomBlob(t, blobsize).MustUpload(t, px)
85 test.RandomBlob(t, blobsize).MustUpload(t, px)
86
87 _, _, err := px.cache.Fetch(ctxbg, tb.BlobRef())
88 if err != nil {
89 t.Fatal("ref should still be in the proxy:", err)
90 }
91
92 test.RandomBlob(t, blobsize).MustUpload(t, px)
93 _, _, err = px.cache.Fetch(ctxbg, tb.BlobRef())
94 if err == nil {
95 t.Fatal("ref should have been evicted from the proxy")
96 }
97
98 _, _, err = px.Fetch(ctxbg, tb.BlobRef())
99 if err != nil {
100 t.Fatal("ref should be available via the proxy fetching from origin:", err)
101 }
102}
103
104func TestMissingGetReturnsNoEnt(t *testing.T) {
105 px, ds := NewProxiedDisk(t)

Callers

nothing calls this directly

Calls 7

RandomBlobFunction · 0.92
NewProxiedDiskFunction · 0.85
MustUploadMethod · 0.80
FatalMethod · 0.80
cleanUpFunction · 0.70
FetchMethod · 0.65
BlobRefMethod · 0.65

Tested by

no test coverage detected