package search import ( "context" "errors" "net/http" "net/http/httptest" "testing" ) // На чистом Meilisearch удаление несуществующего индекса падает в задаче, а не ответом 404. func TestCallMapsFailedIndexTaskToNotFound(t *testing.T) { srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") if r.Method == http.MethodDelete { w.WriteHeader(http.StatusAccepted) _, _ = w.Write([]byte(`{"taskUid":0}`)) return } _, _ = w.Write([]byte(`{"status":"failed","error":{"code":"index_not_found","message":"Index ` + "`x`" + ` not found."}}`)) })) defer srv.Close() err := NewMeili(srv.URL, "").call(context.Background(), http.MethodDelete, "/indexes/x", nil) if !errors.Is(err, ErrMeiliNotFound) { t.Fatalf("err = %v, want ErrMeiliNotFound", err) } }