Skip to content
This repository has been archived by the owner on Oct 8, 2020. It is now read-only.

Commit

Permalink
OnDiskRepoTestCase: Make path option easier to consume. (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
scouten authored Oct 8, 2019
1 parent 3b97ee4 commit 19d290a
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions test/support/test/on_disk_repo_test_case.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,22 @@ defmodule Xgit.Test.OnDiskRepoTestCase do
{:ok, repo!()}
end

@doc ~S"""
Returns a context with an on-disk repository set up.
"""
@spec repo! :: %{tmp_dir: Path.t(), xgit_path: Path.t(), xgit_repo: Repository.t()}
def repo!, do: git_init_repo(TempDirTestCase.tmp_dir!())

@doc ~S"""
Returns a context with an on-disk repository set up.
Unlike `repo!/0`, this takes a hard-wired path and uses that instead.
Ensures that this directory is created and empty.
Use this when debugging tests that fail so you can inspect contents
after the test run.
Can optionally take a hard-wired path to use instead of the default
temporary directory. Use that when you need to debug a test that is
failing and you want to inspect the repo after the test completes.
"""
@spec repo!(dir :: Path.t()) :: %{
@spec repo!(path :: Path.t() | nil) :: %{
tmp_dir: Path.t(),
xgit_path: Path.t(),
xgit_repo: Repository.t()
}
def repo!(path \\ nil)

def repo!(nil), do: git_init_repo(TempDirTestCase.tmp_dir!())

def repo!(dir) when is_binary(dir) do
File.rm_rf!(dir)
File.mkdir!(dir)
Expand Down

0 comments on commit 19d290a

Please sign in to comment.