Skip to content

Commit

Permalink
CoreAPI: don't panic as much in tests
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Łukasz Magiera <[email protected]>
  • Loading branch information
magik6k committed Jan 2, 2019
1 parent 7885a98 commit 184c570
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions core/coreapi/interface/tests/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand All @@ -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" {
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down
12 changes: 6 additions & 6 deletions core/coreapi/interface/tests/dag.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand All @@ -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" {
Expand All @@ -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"))
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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" {
Expand Down

0 comments on commit 184c570

Please sign in to comment.