Skip to content

Commit

Permalink
refactor(fsrepo.test) use TempDir
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Tiger Chow committed Jan 13, 2015
1 parent 3eafb3e commit 01f54d6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
26 changes: 10 additions & 16 deletions repo/fsrepo/fsrepo_test.go
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
package fsrepo

import (
"os"
"path"
"io/ioutil"
"testing"

"github.com/jbenet/go-ipfs/repo/config"
)

// NB: These tests cannot be run in parallel

func init() {
// ensure tests begin in clean state
os.RemoveAll(testRepoDir)
}

const testRepoDir = "./fsrepo_test/repos"

func testRepoPath(p string) string {
return path.Join(testRepoDir, p)
func testRepoPath(p string, t *testing.T) string {
name, err := ioutil.TempDir("", p)
if err != nil {
t.Fatal(err)
}
return name
}

func TestCannotRemoveIfOpen(t *testing.T) {
path := testRepoPath("TestCannotRemoveIfOpen")
path := testRepoPath("TestCannotRemoveIfOpen", t)
AssertNil(Init(path, &config.Config{}), t, "should initialize successfully")
r := At(path)
AssertNil(r.Open(), t)
Expand All @@ -32,8 +26,8 @@ func TestCannotRemoveIfOpen(t *testing.T) {
}

func TestCanManageReposIndependently(t *testing.T) {
pathA := testRepoPath("a")
pathB := testRepoPath("b")
pathA := testRepoPath("a", t)
pathB := testRepoPath("b", t)

t.Log("initialize two repos")
AssertNil(Init(pathA, &config.Config{}), t, "should initialize successfully")
Expand Down
Empty file removed repo/fsrepo/fsrepo_test/.gitkeep
Empty file.
1 change: 0 additions & 1 deletion repo/fsrepo/fsrepo_test/README.md

This file was deleted.

0 comments on commit 01f54d6

Please sign in to comment.