coreapi: don't panic as much in tests

License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>


This commit was moved from ipfs/interface-go-ipfs-core@89157f98ee

This commit was moved from ipfs/boxo@27609c7a83
This commit is contained in:
Łukasz Magiera 2019-01-02 17:41:12 +01:00
parent e5a2d8e6f6
commit f012ef096a
3 changed files with 13 additions and 13 deletions

View File

@ -71,7 +71,7 @@ func TestApi(p Provider) func(t *testing.T) {
select {
case <-zeroRunning:
case <-time.After(time.Second):
t.Errorf("%d node(s) not closed", running)
t.Errorf("%d test swarms(s) not closed", running)
}
})
}

View File

@ -26,12 +26,12 @@ func (tp *provider) TestBlockPut(t *testing.T) {
defer cancel()
api, err := tp.makeAPI(ctx)
if err != nil {
t.Error(err)
t.Fatal(err)
}
res, err := api.Block().Put(ctx, strings.NewReader(`Hello`))
if err != nil {
t.Error(err)
t.Fatal(err)
}
if res.Path().Cid().String() != "QmPyo15ynbVrSTVdJL9th7JysHaAbXt9dM9tXk1bMHbRtk" {
@ -49,7 +49,7 @@ func (tp *provider) TestBlockPutFormat(t *testing.T) {
res, err := api.Block().Put(ctx, strings.NewReader(`Hello`), opt.Block.Format("cbor"))
if err != nil {
t.Error(err)
t.Fatal(err)
}
if res.Path().Cid().String() != "zdpuAn4amuLWo8Widi5v6VQpuo2dnpnwbVE3oB6qqs7mDSeoa" {
@ -85,7 +85,7 @@ func (tp *provider) TestBlockGet(t *testing.T) {
res, err := api.Block().Put(ctx, strings.NewReader(`Hello`), opt.Block.Hash(mh.KECCAK_512, -1))
if err != nil {
t.Error(err)
t.Fatal(err)
}
r, err := api.Block().Get(ctx, res.Path())
@ -126,7 +126,7 @@ func (tp *provider) TestBlockRm(t *testing.T) {
res, err := api.Block().Put(ctx, strings.NewReader(`Hello`))
if err != nil {
t.Error(err)
t.Fatal(err)
}
r, err := api.Block().Get(ctx, res.Path())
@ -180,7 +180,7 @@ func (tp *provider) TestBlockStat(t *testing.T) {
res, err := api.Block().Put(ctx, strings.NewReader(`Hello`))
if err != nil {
t.Error(err)
t.Fatal(err)
}
stat, err := api.Block().Stat(ctx, res.Path())

View File

@ -40,7 +40,7 @@ func (tp *provider) TestPut(t *testing.T) {
res, err := api.Dag().Put(ctx, strings.NewReader(`"Hello"`))
if err != nil {
t.Error(err)
t.Fatal(err)
}
if res.Cid().String() != "zdpuAqckYF3ToF3gcJNxPZXmnmGuXd3gxHCXhq81HGxBejEvv" {
@ -58,7 +58,7 @@ func (tp *provider) TestPutWithHash(t *testing.T) {
res, err := api.Dag().Put(ctx, strings.NewReader(`"Hello"`), opt.Dag.Hash(mh.ID, -1))
if err != nil {
t.Error(err)
t.Fatal(err)
}
if res.Cid().String() != "z5hRLNd2sv4z1c" {
@ -76,12 +76,12 @@ func (tp *provider) TestDagPath(t *testing.T) {
sub, err := api.Dag().Put(ctx, strings.NewReader(`"foo"`))
if err != nil {
t.Error(err)
t.Fatal(err)
}
res, err := api.Dag().Put(ctx, strings.NewReader(`{"lnk": {"/": "`+sub.Cid().String()+`"}}`))
if err != nil {
t.Error(err)
t.Fatal(err)
}
p, err := coreiface.ParsePath(path.Join(res.Cid().String(), "lnk"))
@ -109,7 +109,7 @@ func (tp *provider) TestTree(t *testing.T) {
c, err := api.Dag().Put(ctx, strings.NewReader(`{"a": 123, "b": "foo", "c": {"d": 321, "e": 111}}`))
if err != nil {
t.Error(err)
t.Fatal(err)
}
res, err := api.Dag().Get(ctx, c)
@ -141,7 +141,7 @@ func (tp *provider) TestBatch(t *testing.T) {
c, err := batch.Put(ctx, strings.NewReader(`"Hello"`))
if err != nil {
t.Error(err)
t.Fatal(err)
}
if c.Cid().String() != "zdpuAqckYF3ToF3gcJNxPZXmnmGuXd3gxHCXhq81HGxBejEvv" {