diff options
| author | Carlos Martín Nieto <[email protected]> | 2013-03-06 19:18:41 +0100 |
|---|---|---|
| committer | Carlos Martín Nieto <[email protected]> | 2013-03-07 21:01:21 +0100 |
| commit | 1a7956379497387111191f7f7017167569ef0387 (patch) | |
| tree | 493f86c57d4c68d8ee9bd1fe0a097da08b4969f2 | |
| parent | 0b2f16665d14795047c56feb001d08a2d50fde50 (diff) | |
Factor out creating the test repo
| -rw-r--r-- | index_test.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/index_test.go b/index_test.go index cbcdaa5..c86c322 100644 --- a/index_test.go +++ b/index_test.go @@ -7,7 +7,7 @@ import ( "io/ioutil" ) -func TestCreateRepoAndStage(t *testing.T) { +func createTestRepo(t *testing.T) *Repository { // figure out where we can create the test repo path, err := ioutil.TempDir("", "git2go") checkFatal(t, err) @@ -17,11 +17,17 @@ func TestCreateRepoAndStage(t *testing.T) { tmpfile := "README" err = ioutil.WriteFile(path + "/" + tmpfile, []byte("foo\n"), 0644) checkFatal(t, err) - defer os.RemoveAll(path) + + return repo +} + +func TestCreateRepoAndStage(t *testing.T) { + repo := createTestRepo(t) + defer os.RemoveAll(repo.Path()) idx, err := repo.Index() checkFatal(t, err) - err = idx.AddByPath(tmpfile) + err = idx.AddByPath("README") checkFatal(t, err) treeId, err := idx.WriteTree() checkFatal(t, err) @@ -42,5 +48,5 @@ func checkFatal(t *testing.T, err error) { t.Fatal() } - t.Fatalf("Fail at %v:%v", file, line) + t.Fatalf("Fail at %v:%v; %v", file, line, err) } |
