MCPcopy
hub / github.com/google/go-containerregistry / TestRawConfigFileNotFound

Function TestRawConfigFileNotFound

pkg/v1/remote/image_test.go:230–270  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

228}
229
230func TestRawConfigFileNotFound(t *testing.T) {
231 img := randomImage(t)
232 expectedRepo := "foo/bar"
233 manifestPath := fmt.Sprintf("/v2/%s/manifests/latest", expectedRepo)
234 configPath := fmt.Sprintf("/v2/%s/blobs/%s", expectedRepo, mustConfigName(t, img))
235 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
236 switch r.URL.Path {
237 case configPath:
238 if r.Method != http.MethodGet {
239 t.Errorf("Method; got %v, want %v", r.Method, http.MethodGet)
240 }
241 w.WriteHeader(http.StatusNotFound)
242 case manifestPath:
243 if r.Method != http.MethodGet {
244 t.Errorf("Method; got %v, want %v", r.Method, http.MethodGet)
245 }
246 w.Write(mustRawManifest(t, img))
247 default:
248 t.Fatalf("Unexpected path: %v", r.URL.Path)
249 }
250 }))
251 defer server.Close()
252 u, err := url.Parse(server.URL)
253 if err != nil {
254 t.Fatalf("url.Parse(%v) = %v", server.URL, err)
255 }
256
257 ref := mustNewTag(t, fmt.Sprintf("%s/%s:latest", u.Host, expectedRepo))
258 rmt := remoteImage{
259 ref: ref,
260 ctx: context.Background(),
261 fetcher: fetcher{
262 target: ref.Context(),
263 client: http.DefaultClient,
264 },
265 }
266
267 if _, err := rmt.RawConfigFile(); err == nil {
268 t.Error("RawConfigFile() = nil; wanted error")
269 }
270}
271
272func TestAcceptHeaders(t *testing.T) {
273 img := randomImage(t)

Callers

nothing calls this directly

Calls 9

RawConfigFileMethod · 0.95
randomImageFunction · 0.85
mustConfigNameFunction · 0.85
mustRawManifestFunction · 0.85
mustNewTagFunction · 0.85
CloseMethod · 0.65
ContextMethod · 0.65
WriteMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…