(t *testing.T)
| 228 | } |
| 229 | |
| 230 | func 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 | |
| 272 | func TestAcceptHeaders(t *testing.T) { |
| 273 | img := randomImage(t) |
nothing calls this directly
no test coverage detected
searching dependent graphs…