Hi, I have a test function like this:
test "test one" do
depends = ["joomla_login_plugin", "wordpress_login_plugin", "magento_login_plugin"]
# Create data in db
Enum.map(depends, fn item ->
Map.merge(@new_soft_plugin, %{name: item, depend_type: :hard, depends: List.delete(depends, item)})
|> Map.from_struct()
|> Plugin.create()
end)
# Create state for each data which was imported to db
Enum.map(depends, fn item ->
Map.merge(@new_soft_plugin, %{name: item, depend_type: :hard, depends: List.delete(depends, item)})
|> MishkaInstaller.PluginState.push()
end)
end
If my state is like this, I have no problem:
@impl true
def handle_cast({:push, status, %PluginState{} = element}, state) do
{:noreply, element, state}
end
this state is created without any problem, but if I pass this state to the handle_continue
for adding or editing it to my db like this:
@impl true
def handle_cast({:push, status, %PluginState{} = element}, _state)
{:noreply, state, {:continue, {:sync_with_database, :add}}}
end
@impl true
def handle_continue({:sync_with_database, _status}, %PluginState{} = state) do
state
|> Map.from_struct()
|> Plugin.add_or_edit_by_name()
|> check_output(state)
{:noreply, state}
end
it is stored and if I run mix test
again, I can see the records still exist in test db, but in the top of my test module I added Sandbox
like this:
setup do
:ok = Ecto.Adapters.SQL.Sandbox.checkout(MishkaDatabase.Repo)
end
This is my config:
config :mishka_database, MishkaDatabase.Repo,
username: System.get_env("DATABASE_USER"),
password: System.get_env("DATABASE_PASSWORD"),
database: "#{System.get_env("DATABASE_NAME")}_test#{System.get_env("MIX_TEST_PARTITION")}",
hostname: System.get_env("DATABASE_HOST"),
show_sensitive_data_on_connection_error: true,
pool: Ecto.Adapters.SQL.Sandbox
By the way, my project is umbrella
Thank you, let me know how I can fix this