Packages
ecto_sql
3.5.0-rc.0
3.14.0
3.13.5
3.13.4
3.13.3
3.13.2
3.13.1
3.13.0
3.12.1
3.12.0
3.11.3
3.11.2
3.11.1
3.11.0
3.10.2
3.10.1
3.10.0
3.9.2
3.9.1
3.9.0
3.8.3
3.8.2
3.8.1
3.8.0
3.7.2
3.7.1
3.7.0
3.6.2
3.6.1
3.6.0
3.5.4
3.5.3
3.5.2
3.5.1
3.5.0
3.5.0-rc.1
3.5.0-rc.0
3.4.5
3.4.4
3.4.3
3.4.2
3.4.1
3.4.0
3.3.4
3.3.3
3.3.2
3.3.1
3.3.0
3.2.2
3.2.1
3.2.0
3.1.6
3.1.5
3.1.4
3.1.3
3.1.2
3.1.1
3.1.0
3.0.5
3.0.4
3.0.3
3.0.2
3.0.1
3.0.0
3.0.0-rc.1
3.0.0-rc.0
SQL-based adapters for Ecto and database migrations
Current section
Files
Jump to
Current section
Files
integration_test/support/file_helpers.exs
defmodule Support.FileHelpers do
import ExUnit.Assertions
@doc """
Returns the `tmp_path` for tests.
"""
def tmp_path do
Path.expand("../../tmp", __DIR__)
end
@doc """
Executes the given function in a temp directory
tailored for this test case and test.
"""
defmacro in_tmp(fun) do
path = Path.join([tmp_path(), "#{__CALLER__.module}", "#{elem(__CALLER__.function, 0)}"])
quote do
path = unquote(path)
File.rm_rf!(path)
File.mkdir_p!(path)
File.cd!(path, fn -> unquote(fun).(path) end)
end
end
@doc """
Asserts a file was generated.
"""
def assert_file(file) do
assert File.regular?(file), "Expected #{file} to exist, but does not"
end
@doc """
Asserts a file was generated and that it matches a given pattern.
"""
def assert_file(file, callback) when is_function(callback, 1) do
assert_file(file)
callback.(File.read!(file))
end
def assert_file(file, match) do
assert_file file, &(assert &1 =~ match)
end
end