You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For some reason delete does not actually delete a message. Here is a relevant test. You can skip first three lines related to phoenix, it is related to the code writing to amnesia.
test "server receives message, stores it and replies with `received` status", %{socket: socket, user: user, chat: chat} do
{:ok, _, socket} = subscribe_and_join(socket, "chats:#{chat.id}", %{})
ref = push socket, "message", %{body: "the body", client_id: 1, created_at: :os.system_time(:seconds)}
assert_reply ref, :ok, %{client_id: 1, status: "received"}
[message] = Amnesia.transaction do
selection = Message.where chat_id == chat.id, select: [id, body, client_id, chat_id, created_at, status, user_id]
selection
|> Amnesia.Selection.values
end
chat_id = chat.id
user_id = user.id
assert [id, "the body", 1, ^chat_id, _, "received", ^user_id] = message
# Trying to delete here
status = Amnesia.transaction do
IO.inspect Message.last
Message.last |> Message.delete
end
IO.inspect status
# receiving ** (MatchError) no match of right hand side value: [[1, "the body", 1, 293, 1465198234, "received", 1514]]
[] = Amnesia.transaction do
selection = Message.where chat_id == chat.id, select: [id, body, client_id, chat_id, created_at, status, user_id]
selection
|> Amnesia.Selection.values
end
end
The text was updated successfully, but these errors were encountered:
For some reason delete does not actually delete a message. Here is a relevant test. You can skip first three lines related to phoenix, it is related to the code writing to amnesia.
The text was updated successfully, but these errors were encountered: