offline_test.go 609 Bytes
Newer Older
1 2 3 4
package bitswap

import (
	"testing"
5 6

	context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
7 8 9 10 11 12 13

	u "github.com/jbenet/go-ipfs/util"
	testutil "github.com/jbenet/go-ipfs/util/testutil"
)

func TestBlockReturnsErr(t *testing.T) {
	off := NewOfflineExchange()
14
	_, err := off.Block(context.Background(), u.Key("foo"))
15 16 17 18 19 20 21 22 23
	if err != nil {
		return // as desired
	}
	t.Fail()
}

func TestHasBlockReturnsNil(t *testing.T) {
	off := NewOfflineExchange()
	block := testutil.NewBlockOrFail(t, "data")
24
	err := off.HasBlock(context.Background(), block)
25 26 27 28
	if err != nil {
		t.Fatal("")
	}
}