Skip to content

Commit 3ab1973

Browse files
committed
Cleanup tmp git folder after tests
The OS automatically cleans up that folder, but it takes no effort on removing them after the test suite.
1 parent c8509af commit 3ab1973

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

test/support/git_project_case.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
defmodule GitHooks.TestSupport.GitProjectCase do
22
@moduledoc """
33
This module provides a setup that creates a tmp git project
4-
for the testing context
4+
for the testing context.
55
"""
66

77
use ExUnit.CaseTemplate
88

99
using do
1010
quote do
1111
setup do
12-
# Create a temporary directory
1312
tmp_dir = Path.join(System.tmp_dir!(), "git_hooks_test_#{:os.system_time(:millisecond)}")
1413
File.mkdir_p!(tmp_dir)
1514

16-
# Initialize a git repository in the temporary directory
1715
System.cmd("git", ["init"], cd: tmp_dir)
1816

19-
# Set the :project_path in Application environment
2017
Application.put_env(:git_hooks, :project_path, tmp_dir)
2118

22-
# Return the context with the tmp_dir
19+
on_exit(fn ->
20+
File.rm_rf(tmp_dir)
21+
end)
22+
2323
{:ok, tmp_dir: tmp_dir}
2424
end
2525
end

0 commit comments

Comments
 (0)