B Meilisearch: Update to current API responses.

This commit is contained in:
Lain Soykaf 2023-11-12 16:43:50 +04:00
parent a1a25029da
commit 59018d73c3
2 changed files with 20 additions and 6 deletions

View File

@ -76,7 +76,7 @@ defmodule Pleroma.Search.Meilisearch do
) do ) do
:ok :ok
else else
_ -> :error _ -> {:error, "Could not remove from index"}
end end
end end
@ -159,8 +159,7 @@ defmodule Pleroma.Search.Meilisearch do
[maybe_search_data] [maybe_search_data]
) )
with {:ok, res} <- result, with {:ok, %{"status" => "enqueued"}} <- result do
true <- Map.has_key?(res, "updateId") do
# Added successfully # Added successfully
:ok :ok
else else

View File

@ -34,7 +34,15 @@ defmodule Pleroma.Search.MeilisearchTest do
# To make sure that the worker is called # To make sure that the worker is called
send(self(), "posted_to_meilisearch") send(self(), "posted_to_meilisearch")
json(%{updateId: 1})
%{
"enqueuedAt" => "2023-11-12T12:36:46.927517Z",
"indexUid" => "objects",
"status" => "enqueued",
"taskUid" => 6,
"type" => "documentAdditionOrUpdate"
}
|> json()
end) end)
Config Config
@ -103,12 +111,19 @@ defmodule Pleroma.Search.MeilisearchTest do
Jason.decode!(body) Jason.decode!(body)
) )
json(%{updateId: 1}) %{
"enqueuedAt" => "2023-11-12T12:36:46.927517Z",
"indexUid" => "objects",
"status" => "enqueued",
"taskUid" => 6,
"type" => "documentAdditionOrUpdate"
}
|> json()
%{method: :delete, url: "http://127.0.0.1:7700/indexes/objects/documents/" <> id} -> %{method: :delete, url: "http://127.0.0.1:7700/indexes/objects/documents/" <> id} ->
send(self(), "called_delete") send(self(), "called_delete")
assert String.length(id) > 1 assert String.length(id) > 1
json(%{updateId: 2}) json(%{})
end) end)
Config Config