From e300945a3d456af1b619447347cd19a779b7a8f5 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Fri, 24 Apr 2015 12:59:29 +0200 Subject: tests: always clean up temporary repository dirs Some test repositories are not correctly removed after the tests did run. Fix by introducing a function that is to be used for cleaning up temporary test repositories. --- git_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'git_test.go') diff --git a/git_test.go b/git_test.go index b9cf0a9..58caf71 100644 --- a/git_test.go +++ b/git_test.go @@ -2,11 +2,24 @@ package git import ( "io/ioutil" + "os" "path" "testing" "time" ) +func cleanupTestRepo(t *testing.T, r *Repository) { + var err error + if r.IsBare() { + err = os.RemoveAll(r.Path()) + } else { + err = os.RemoveAll(r.Workdir()) + } + checkFatal(t, err) + + r.Free() +} + func createTestRepo(t *testing.T) *Repository { // figure out where we can create the test repo path, err := ioutil.TempDir("", "git2go") -- cgit v1.2.3