Improved tmpfile setup and teardown for tests
This commit is contained in:
parent
fecea9cc2f
commit
6ffa0d0477
3 changed files with 15 additions and 5 deletions
|
|
@ -34,6 +34,7 @@ defmodule PinchflatWeb.ConnCase do
|
||||||
|
|
||||||
setup tags do
|
setup tags do
|
||||||
Pinchflat.DataCase.setup_sandbox(tags)
|
Pinchflat.DataCase.setup_sandbox(tags)
|
||||||
|
Pinchflat.DataCase.setup_temp_filepaths()
|
||||||
{:ok, conn: Phoenix.ConnTest.build_conn()}
|
{:ok, conn: Phoenix.ConnTest.build_conn()}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,20 @@ defmodule Pinchflat.DataCase do
|
||||||
|
|
||||||
setup tags do
|
setup tags do
|
||||||
Pinchflat.DataCase.setup_sandbox(tags)
|
Pinchflat.DataCase.setup_sandbox(tags)
|
||||||
|
Pinchflat.DataCase.setup_temp_filepaths()
|
||||||
|
:ok
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Sets up the temp filepaths for the media and metadata directories.
|
||||||
|
"""
|
||||||
|
def setup_temp_filepaths do
|
||||||
|
File.rm_rf!(Application.get_env(:pinchflat, :media_directory))
|
||||||
|
File.rm_rf!(Application.get_env(:pinchflat, :metadata_directory))
|
||||||
|
|
||||||
|
File.mkdir_p!(Application.get_env(:pinchflat, :media_directory))
|
||||||
|
File.mkdir_p!(Application.get_env(:pinchflat, :metadata_directory))
|
||||||
|
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,3 @@ Application.put_env(:pinchflat, :yt_dlp_runner, YtDlpRunnerMock)
|
||||||
ExUnit.start()
|
ExUnit.start()
|
||||||
Ecto.Adapters.SQL.Sandbox.mode(Pinchflat.Repo, :manual)
|
Ecto.Adapters.SQL.Sandbox.mode(Pinchflat.Repo, :manual)
|
||||||
Faker.start()
|
Faker.start()
|
||||||
|
|
||||||
setup_all do
|
|
||||||
File.rm_rf(Application.get_env(:pinchflat, :media_directory))
|
|
||||||
File.rm_rf(Application.get_env(:pinchflat, :metadata_directory))
|
|
||||||
end
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue