coreapi: don't panic as much in tests
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
Łukasz Magiera committed
Jan 2, 2019 at 17:41 UTC
44fc750c7e50ef0211c1c590ca6808557c101475
3 files changed
+13
-13
core/coreapi/interface/tests/api.go
+1
-1
@@ -71,7 +71,7 @@ func TestApi(p Provider) func(t *testing.T) {
71
select {
72
case <-zeroRunning:
73
case <-time.After(time.Second):
74
- t.Errorf("%d node(s) not closed", running)
74
+ t.Errorf("%d test swarms(s) not closed", running)
75
}
76
})
77
}
core/coreapi/interface/tests/block.go
+6
-6
@@ -26,12 +26,12 @@ func (tp *provider) TestBlockPut(t *testing.T) {
26
defer cancel()
27
api, err := tp.makeAPI(ctx)
28
if err != nil {
29
- t.Error(err)
29
+ t.Fatal(err)
30
}
31
32
res, err := api.Block().Put(ctx, strings.NewReader(`Hello`))
33
if err != nil {
34
- t.Error(err)
34
+ t.Fatal(err)
35
}
36
37
if res.Path().Cid().String() != "QmPyo15ynbVrSTVdJL9th7JysHaAbXt9dM9tXk1bMHbRtk" {
@@ -49,7 +49,7 @@ func (tp *provider) TestBlockPutFormat(t *testing.T) {
49
50
res, err := api.Block().Put(ctx, strings.NewReader(`Hello`), opt.Block.Format("cbor"))
51
if err != nil {
52
- t.Error(err)
52
+ t.Fatal(err)
53
}
54
55
if res.Path().Cid().String() != "zdpuAn4amuLWo8Widi5v6VQpuo2dnpnwbVE3oB6qqs7mDSeoa" {
@@ -85,7 +85,7 @@ func (tp *provider) TestBlockGet(t *testing.T) {
85
86
res, err := api.Block().Put(ctx, strings.NewReader(`Hello`), opt.Block.Hash(mh.KECCAK_512, -1))
87
if err != nil {
88
- t.Error(err)
88
+ t.Fatal(err)
89
}
90
91
r, err := api.Block().Get(ctx, res.Path())
@@ -126,7 +126,7 @@ func (tp *provider) TestBlockRm(t *testing.T) {
126
127
res, err := api.Block().Put(ctx, strings.NewReader(`Hello`))
128
if err != nil {
129
- t.Error(err)
129
+ t.Fatal(err)
130
}
131
132
r, err := api.Block().Get(ctx, res.Path())
@@ -180,7 +180,7 @@ func (tp *provider) TestBlockStat(t *testing.T) {
180
181
res, err := api.Block().Put(ctx, strings.NewReader(`Hello`))
182
if err != nil {
183
- t.Error(err)
183
+ t.Fatal(err)
184
}
185
186
stat, err := api.Block().Stat(ctx, res.Path())
core/coreapi/interface/tests/dag.go
+6
-6
@@ -40,7 +40,7 @@ func (tp *provider) TestPut(t *testing.T) {
40
41
res, err := api.Dag().Put(ctx, strings.NewReader(`"Hello"`))
42
if err != nil {
43
- t.Error(err)
43
+ t.Fatal(err)
44
}
45
46
if res.Cid().String() != "zdpuAqckYF3ToF3gcJNxPZXmnmGuXd3gxHCXhq81HGxBejEvv" {
@@ -58,7 +58,7 @@ func (tp *provider) TestPutWithHash(t *testing.T) {
58
59
res, err := api.Dag().Put(ctx, strings.NewReader(`"Hello"`), opt.Dag.Hash(mh.ID, -1))
60
if err != nil {
61
- t.Error(err)
61
+ t.Fatal(err)
62
}
63
64
if res.Cid().String() != "z5hRLNd2sv4z1c" {
@@ -76,12 +76,12 @@ func (tp *provider) TestDagPath(t *testing.T) {
76
77
sub, err := api.Dag().Put(ctx, strings.NewReader(`"foo"`))
78
if err != nil {
79
- t.Error(err)
79
+ t.Fatal(err)
80
}
81
82
res, err := api.Dag().Put(ctx, strings.NewReader(`{"lnk": {"/": "`+sub.Cid().String()+`"}}`))
83
if err != nil {
84
- t.Error(err)
84
+ t.Fatal(err)
85
}
86
87
p, err := coreiface.ParsePath(path.Join(res.Cid().String(), "lnk"))
@@ -109,7 +109,7 @@ func (tp *provider) TestTree(t *testing.T) {
109
110
c, err := api.Dag().Put(ctx, strings.NewReader(`{"a": 123, "b": "foo", "c": {"d": 321, "e": 111}}`))
111
if err != nil {
112
- t.Error(err)
112
+ t.Fatal(err)
113
}
114
115
res, err := api.Dag().Get(ctx, c)
@@ -141,7 +141,7 @@ func (tp *provider) TestBatch(t *testing.T) {
141
142
c, err := batch.Put(ctx, strings.NewReader(`"Hello"`))
143
if err != nil {
144
- t.Error(err)
144
+ t.Fatal(err)
145
}
146
147
if c.Cid().String() != "zdpuAqckYF3ToF3gcJNxPZXmnmGuXd3gxHCXhq81HGxBejEvv" {