(t *testing.T)
| 67 | } |
| 68 | |
| 69 | func TestLayersLazy(t *testing.T) { |
| 70 | img, err := random.Image(1024, 5) |
| 71 | if err != nil { |
| 72 | t.Fatalf("random.Image: %v", err) |
| 73 | } |
| 74 | m := &memcache{map[v1.Hash]v1.Layer{}} |
| 75 | img = Image(img, m) |
| 76 | |
| 77 | layers, err := img.Layers() |
| 78 | if err != nil { |
| 79 | t.Fatalf("img.Layers: %v", err) |
| 80 | } |
| 81 | |
| 82 | // After calling Layers, nothing is cached. |
| 83 | if got, want := len(m.m), 0; got != want { |
| 84 | t.Errorf("Cache has %d entries, want %d", got, want) |
| 85 | } |
| 86 | |
| 87 | rc, err := layers[0].Uncompressed() |
| 88 | if err != nil { |
| 89 | t.Fatalf("layer.Uncompressed: %v", err) |
| 90 | } |
| 91 | io.Copy(io.Discard, rc) |
| 92 | |
| 93 | if got, expected := len(m.m), 1; got != expected { |
| 94 | t.Errorf("expected %v layers in cache after reading, got %v", expected, got) |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | // TestCacheShortCircuit tests that if a layer is found in the cache, |
| 99 | // LayerByDigest is not called in the underlying Image implementation. |
nothing calls this directly
no test coverage detected
searching dependent graphs…