Deleting a missing <uid>_next index is accepted with 202 and fails inside the task with index_not_found. That error was not treated as not-found, so the first reindex aborted and search stayed unavailable until indexes existed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
29 lines
924 B
Go
29 lines
924 B
Go
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)
|
|
}
|
|
}
|