tests: properly setup and teardown

This commit is contained in:
Carlos Martín Nieto
2013-09-02 20:10:38 +02:00
parent 8f9ca440d9
commit 895041b2a7
2 changed files with 22 additions and 8 deletions

View File

@@ -3,17 +3,21 @@ Code.require_file "../test_helper.exs", __FILE__
defmodule ObjectTest do defmodule ObjectTest do
use ExUnit.Case use ExUnit.Case
use Geef use Geef
import RepoHelpers
defp tmp_dir do setup do
{a, b, c} = :erlang.now() {{:ok, repo}, path} = tmp_bare()
n = node() {:ok, [repo: repo, path: path]}
dir = :io_lib.format("geef-~p~p~p~p.git", [n, a, b, c])
Path.join(System.tmp_dir!, dir)
end end
test "object OO helpers" do teardown meta do
dir = tmp_dir Repository.stop(meta[:repo])
{ :ok, repo } = Repository.init(dir, true) File.rm_rf!(meta[:path])
:ok
end
test "object OO helpers", meta do
repo = meta[:repo]
{ :ok, odb } = Repository.odb(repo) { :ok, odb } = Repository.odb(repo)
#{ :ok, index } = :geef_index.new #{ :ok, index } = :geef_index.new

View File

@@ -1 +1,11 @@
ExUnit.start ExUnit.start
defmodule RepoHelpers do
def tmp_bare do
{a, b, c} = :erlang.now()
n = node()
dir = :io_lib.format("geef-~p~p~p~p.git", [n, a, b, c])
path = Path.join(System.tmp_dir!, dir)
{Geef.Repository.init(path, true), path}
end
end