@cryptotaxi247 / kubo / commits / 9acc02461

test(fsrepo) harden tests

Brian Tiger Chow committed Jan 14, 2015 at 05:42 UTC 9acc02461ebe739cb0e73a7b8e819404840d81fd
1 file changed +16 -6
repo/fsrepo/fsrepo_test.go
+16 -6
@@ -30,14 +30,18 @@ func TestCanManageReposIndependently(t *testing.T) {
30 pathB := testRepoPath("b", t)
31
32 t.Log("initialize two repos")
33 - AssertNil(Init(pathA, &config.Config{}), t, "should initialize successfully")
34 - AssertNil(Init(pathB, &config.Config{}), t, "should initialize successfully")
33 + AssertNil(Init(pathA, &config.Config{}), t, "a", "should initialize successfully")
34 + AssertNil(Init(pathB, &config.Config{}), t, "b", "should initialize successfully")
35 +
36 + t.Log("ensure repos initialized")
37 + Assert(IsInitialized(pathA), t, "a should be initialized")
38 + Assert(IsInitialized(pathB), t, "b should be initialized")
39
40 t.Log("open the two repos")
41 repoA := At(pathA)
42 repoB := At(pathB)
39 - AssertNil(repoA.Open(), t)
40 - AssertNil(repoB.Open(), t)
43 + AssertNil(repoA.Open(), t, "a")
44 + AssertNil(repoB.Open(), t, "b")
45
46 t.Log("close and remove b while a is open")
47 AssertNil(repoB.Close(), t, "close b")
@@ -50,12 +54,18 @@ func TestCanManageReposIndependently(t *testing.T) {
54
55 func AssertNil(err error, t *testing.T, msgs ...string) {
56 if err != nil {
53 - t.Error(msgs, "error:", err)
57 + t.Fatal(msgs, "error:", err)
58 + }
59 +}
60 +
61 +func Assert(v bool, t *testing.T, msgs ...string) {
62 + if !v {
63 + t.Fatal(msgs)
64 }
65 }
66
67 func AssertErr(err error, t *testing.T, msgs ...string) {
68 if err == nil {
59 - t.Error(msgs, "error:", err)
69 + t.Fatal(msgs, "error:", err)
70 }
71 }