MCPcopy Index your code
hub / github.com/regclient/regclient / TestImageConfig

Function TestImageConfig

image_test.go:163–253  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

161}
162
163func TestImageConfig(t *testing.T) {
164 t.Parallel()
165 ctx := context.Background()
166 regHandler := olareg.New(oConfig.Config{
167 Storage: oConfig.ConfigStorage{
168 StoreType: oConfig.StoreMem,
169 RootDir: "./testdata",
170 },
171 })
172 ts := httptest.NewServer(regHandler)
173 t.Cleanup(func() {
174 ts.Close()
175 _ = regHandler.Close()
176 })
177 tsURL, _ := url.Parse(ts.URL)
178 tsHost := tsURL.Host
179 rcHosts := []config.Host{
180 {
181 Name: tsHost,
182 Hostname: tsHost,
183 TLS: config.TLSDisabled,
184 },
185 }
186 log := slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: slog.LevelWarn}))
187 delayInit, _ := time.ParseDuration("0.05s")
188 delayMax, _ := time.ParseDuration("0.10s")
189 rc := New(
190 WithConfigHost(rcHosts...),
191 WithSlog(log),
192 WithRegOpts(reg.WithDelay(delayInit, delayMax)),
193 )
194 tt := []struct {
195 name string
196 r string
197 opts []ImageOpts
198 expectErr error
199 expectArch string
200 expectOS string
201 }{
202 {
203 name: "ocidir-v1-amd64",
204 r: "ocidir://testdata/testrepo:v1",
205 opts: []ImageOpts{ImageWithPlatform("linux/amd64")},
206 expectArch: "amd64",
207 expectOS: "linux",
208 },
209 {
210 name: "ocidir-not-found",
211 r: "ocidir://testdata/testrepo:missing",
212 expectErr: errs.ErrNotFound,
213 },
214 {
215 name: "ocidir-a1",
216 r: "ocidir://testdata/testrepo:a1",
217 opts: []ImageOpts{},
218 expectErr: errs.ErrUnsupportedMediaType,
219 },
220 {

Callers

nothing calls this directly

Calls 11

WithDelayFunction · 0.92
NewFunction · 0.92
WithConfigHostFunction · 0.85
WithRegOptsFunction · 0.85
ImageWithPlatformFunction · 0.85
ParseMethod · 0.80
ImageConfigMethod · 0.80
NewFunction · 0.70
WithSlogFunction · 0.70
CloseMethod · 0.65
GetConfigMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…