🌲 alog (Append-only Log) is an easy way to start using the Lambda/Kappa architecture in your Elixir/Phoenix Apps while still using PostgreSQL (with Ecto).
Okay, this is a weird bug that I think is coming from my code, not the alog module.
I have some fairly standard Phoenix-style ExUnit tests that test the creation and deletion of certain resources that use the Alog module in their schema files.
I have resource one, SomeItem, with a deletion test that passes like so:
def some_item_fixture(attrs \\ %{}) do
{:ok, %User{} = user} = SomeContext.create_user(@user_valid_attrs)
{:ok, some_item} =
attrs
|> Enum.into(@valid_attrs)
|> Map.put(:user_id, user.id)
|> SomeContext.create_some_item()
some_item
end
test "delete_some_item/1 deletes the some_item" do
some_item = some_item_fixture()
assert {:ok, %SomeItem{}} = SomeContext.delete_some_item(some_item) # calls SomeItem.delete(some_item)
assert_raise Ecto.NoResultsError, fn -> SomeItem.get!(some_item.uuid) end
end
I have resource two, SecondItem, for which the deletion test does not pass:
def second_item_fixture(attrs \\ %{}) do
{:ok, %SomePlace{} = some_place} = OtherContext.create_some_place(@valid_some_place_attrs)
new_type_attrs =
@valid_second_item_attrs
|> Map.put(:some_place_id, some_place.id)
{:ok, %SecondItem{} = second_item} = SomeContext.create_second_item(new_type_attrs)
second_item
end
test "delete_second_item/1 deletes the second_item" do
second_item = second_item_fixture()
assert {:ok, %SecondItem{}} = SomeContext.delete_second_item(second_item) # calls SecondItem.delete(some_item)
assert_raise Ecto.NoResultsError, fn -> SecondItem.get!(second_item.uuid) end
end
The delete_second_item test fails on the Ecto.NoResultsError, and when I assert that a regular get/1 returns nil, the get returns the entire %SecondItem{} struct with deleted: false
The schemas for both resources are nearly identical, using the same use ALog declaration at the beginning of each module, and when I run the same functions in order for the SecondItem above either in app or in iex, I get the expected result.
Okay, this is a weird bug that I think is coming from my code, not the alog module.
I have some fairly standard Phoenix-style ExUnit tests that test the creation and deletion of certain resources that use the Alog module in their schema files.
I have resource one, SomeItem, with a deletion test that passes like so:
I have resource two, SecondItem, for which the deletion test does not pass:
The delete_second_item test fails on the Ecto.NoResultsError, and when I assert that a regular get/1 returns
nil
, the get returns the entire%SecondItem{}
struct withdeleted: false
The schemas for both resources are nearly identical, using the same
use ALog
declaration at the beginning of each module, and when I run the same functions in order for the SecondItem above either in app or in iex, I get the expected result.Any ideas/suggestions would be appreciated :P