summaryrefslogtreecommitdiff
path: root/index_test.go
diff options
context:
space:
mode:
authorPatrick Steinhardt <[email protected]>2015-04-24 12:59:29 +0200
committerPatrick Steinhardt <[email protected]>2015-04-24 13:01:51 +0200
commite300945a3d456af1b619447347cd19a779b7a8f5 (patch)
tree3e37d99c8266d130ea54b2080e20199e8073e99e /index_test.go
parente021457f27654ea0f1ec41963c6da62c168be853 (diff)
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.
Diffstat (limited to 'index_test.go')
-rw-r--r--index_test.go13
1 files changed, 6 insertions, 7 deletions
diff --git a/index_test.go b/index_test.go
index 98d9a31..647a0b8 100644
--- a/index_test.go
+++ b/index_test.go
@@ -2,14 +2,13 @@ package git
import (
"io/ioutil"
- "os"
"runtime"
"testing"
)
func TestCreateRepoAndStage(t *testing.T) {
repo := createTestRepo(t)
- defer os.RemoveAll(repo.Workdir())
+ defer cleanupTestRepo(t, repo)
idx, err := repo.Index()
checkFatal(t, err)
@@ -25,10 +24,10 @@ func TestCreateRepoAndStage(t *testing.T) {
func TestIndexWriteTreeTo(t *testing.T) {
repo := createTestRepo(t)
- defer os.RemoveAll(repo.Workdir())
+ defer cleanupTestRepo(t, repo)
repo2 := createTestRepo(t)
- defer os.RemoveAll(repo.Workdir())
+ defer cleanupTestRepo(t, repo2)
idx, err := repo.Index()
checkFatal(t, err)
@@ -44,7 +43,7 @@ func TestIndexWriteTreeTo(t *testing.T) {
func TestIndexAddAndWriteTreeTo(t *testing.T) {
repo := createTestRepo(t)
- defer os.RemoveAll(repo.Workdir())
+ defer cleanupTestRepo(t, repo)
odb, err := repo.Odb()
checkFatal(t, err)
@@ -74,7 +73,7 @@ func TestIndexAddAndWriteTreeTo(t *testing.T) {
func TestIndexAddAllNoCallback(t *testing.T) {
repo := createTestRepo(t)
- defer os.RemoveAll(repo.Workdir())
+ defer cleanupTestRepo(t, repo)
err := ioutil.WriteFile(repo.Workdir()+"/README", []byte("foo\n"), 0644)
checkFatal(t, err)
@@ -95,7 +94,7 @@ func TestIndexAddAllNoCallback(t *testing.T) {
func TestIndexAddAllCallback(t *testing.T) {
repo := createTestRepo(t)
- defer os.RemoveAll(repo.Workdir())
+ defer cleanupTestRepo(t, repo)
err := ioutil.WriteFile(repo.Workdir()+"/README", []byte("foo\n"), 0644)
checkFatal(t, err)