(t *testing.T)
| 72 | } |
| 73 | |
| 74 | func 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 | |
| 104 | func TestMissingGetReturnsNoEnt(t *testing.T) { |
| 105 | px, ds := NewProxiedDisk(t) |
nothing calls this directly
no test coverage detected