MCPcopy Create free account
hub / github.com/conforma/cli / TestCustomExtractor

Function TestCustomExtractor

internal/fetchers/oci/files/files_test.go:98–125  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

96}
97
98func 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
127func TestShouldFilter(t *testing.T) {
128 cases := []struct {

Callers

nothing calls this directly

Calls 3

WithClientFunction · 0.92
ImageFilesFunction · 0.85
ImageMethod · 0.65

Tested by

no test coverage detected