package v2 import ( "context" "net/http/httptest" "testing" "github.com/go-chi/chi/v5" ) type fakeEvictor struct{ remote, path string } func (f *fakeEvictor) Evict(_ context.Context, remote, path string) error { f.remote, f.path = remote, path return nil } func TestRemoteEvictDelegatesToEvictor(t *testing.T) { for _, path := range []string{"8/Everything/x86_64/repodata/repomd.xml", "8/Everything/x86_64/repodata/*"} { ev := &fakeEvictor{} h := NewObjectsHandler(nil, ev) router := chi.NewRouter() router.Route("/remotes/{name}/objects", func(r chi.Router) { r.Delete("/*", h.Routes().ServeHTTP) }) w := httptest.NewRecorder() router.ServeHTTP(w, httptest.NewRequest("DELETE", "/remotes/epel/objects/"+path, nil)) if w.Code != 204 || ev.remote != "epel" || ev.path != path { t.Errorf("DELETE %s: code=%d evicted=%q/%q", path, w.Code, ev.remote, ev.path) } } }