(t *testing.T)
| 96 | } |
| 97 | |
| 98 | func TestCustomExtractor(t *testing.T) { |
| 99 | ref := name.MustParseReference("registry.io/repository/image:tag") |
| 100 | |
| 101 | image, err := crane.Image(map[string][]byte{ |
| 102 | "autoexec.bat": []byte(`@ECHO OFF`), |
| 103 | "manifests/a.json": []byte(`{"a":1}`), |
| 104 | "manifests/b.yaml": []byte(`b: 2`), |
| 105 | "manifests/c.xml": []byte(`<?xml version="1.0" encoding="UTF-8"?>`), |
| 106 | "manifests/unreadable.yaml": []byte(`***`), |
| 107 | "manifests/unreadable.json": []byte(`***`), |
| 108 | }) |
| 109 | require.NoError(t, err) |
| 110 | |
| 111 | client := fake.FakeClient{} |
| 112 | client.On("Image", ref).Return(image, nil) |
| 113 | |
| 114 | ctx := oci.WithClient(context.Background(), &client) |
| 115 | |
| 116 | extractors := []Extractor{PathExtractor{Path: "manifests"}} |
| 117 | files, err := ImageFiles(ctx, ref, extractors) |
| 118 | |
| 119 | assert.NoError(t, err) |
| 120 | |
| 121 | assert.Equal(t, map[string]json.RawMessage{ |
| 122 | "manifests/a.json": []byte(`{"a":1}`), |
| 123 | "manifests/b.yaml": []byte(`{"b":2}`), |
| 124 | }, files) |
| 125 | } |
| 126 | |
| 127 | func TestShouldFilter(t *testing.T) { |
| 128 | cases := []struct { |
nothing calls this directly
no test coverage detected