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. --- reference_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'reference_test.go') diff --git a/reference_test.go b/reference_test.go index c7d52fb..d6b5f22 100644 --- a/reference_test.go +++ b/reference_test.go @@ -1,7 +1,6 @@ package git import ( - "os" "runtime" "sort" "testing" @@ -10,7 +9,7 @@ import ( func TestRefModification(t *testing.T) { repo := createTestRepo(t) - defer os.RemoveAll(repo.Workdir()) + defer cleanupTestRepo(t, repo) commitId, treeId := seedTestRepo(t, repo) @@ -62,7 +61,7 @@ func TestRefModification(t *testing.T) { func TestReferenceIterator(t *testing.T) { repo := createTestRepo(t) - defer os.RemoveAll(repo.Workdir()) + defer cleanupTestRepo(t, repo) loc, err := time.LoadLocation("Europe/Berlin") checkFatal(t, err) @@ -140,7 +139,8 @@ func TestReferenceIterator(t *testing.T) { func TestReferenceOwner(t *testing.T) { repo := createTestRepo(t) - defer os.RemoveAll(repo.Workdir()) + defer cleanupTestRepo(t, repo) + commitId, _ := seedTestRepo(t, repo) ref, err := repo.CreateReference("refs/heads/foo", commitId, true, nil, "") @@ -158,7 +158,7 @@ func TestReferenceOwner(t *testing.T) { func TestUtil(t *testing.T) { repo := createTestRepo(t) - defer os.RemoveAll(repo.Workdir()) + defer cleanupTestRepo(t, repo) commitId, _ := seedTestRepo(t, repo) -- cgit v1.2.3 From 53c158fbd7e5f4dac787f5c3a7107fcb4116f676 Mon Sep 17 00:00:00 2001 From: taylorchu Date: Sat, 30 May 2015 22:27:08 +0200 Subject: Fix test error messages --- index_test.go | 3 +-- reference_test.go | 3 +-- submodule_test.go | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) (limited to 'reference_test.go') diff --git a/index_test.go b/index_test.go index 9283b83..7c65f4f 100644 --- a/index_test.go +++ b/index_test.go @@ -188,8 +188,7 @@ func checkFatal(t *testing.T, err error) { // The failure happens at wherever we were called, not here _, file, line, ok := runtime.Caller(1) if !ok { - t.Fatal() + t.Fatalf("Unable to get caller") } - t.Fatalf("Fail at %v:%v; %v", file, line, err) } diff --git a/reference_test.go b/reference_test.go index d6b5f22..5720a66 100644 --- a/reference_test.go +++ b/reference_test.go @@ -199,8 +199,7 @@ func checkRefType(t *testing.T, ref *Reference, kind ReferenceType) { // The failure happens at wherever we were called, not here _, file, line, ok := runtime.Caller(1) if !ok { - t.Fatal() + t.Fatalf("Unable to get caller") } - t.Fatalf("Wrong ref type at %v:%v; have %v, expected %v", file, line, ref.Type(), kind) } diff --git a/submodule_test.go b/submodule_test.go index ee75d53..27bc193 100644 --- a/submodule_test.go +++ b/submodule_test.go @@ -21,6 +21,6 @@ func TestSubmoduleForeach(t *testing.T) { checkFatal(t, err) if i != 1 { - t.Fatalf("expected one submodule found but got %i", i) + t.Fatalf("expected one submodule found but got %d", i) } } -- cgit v1.2.3