offline_test.go 580 Bytes
Newer Older
Jeromy's avatar
Jeromy committed
1
package offline
2 3 4 5 6 7

import (
	"testing"

	context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"

8
	blocks "github.com/jbenet/go-ipfs/blocks"
9 10 11 12
	u "github.com/jbenet/go-ipfs/util"
)

func TestBlockReturnsErr(t *testing.T) {
Brian Tiger Chow's avatar
Brian Tiger Chow committed
13
	off := Exchange()
Jeromy's avatar
Jeromy committed
14
	_, err := off.GetBlock(context.Background(), u.Key("foo"))
15 16 17 18 19 20 21
	if err != nil {
		return // as desired
	}
	t.Fail()
}

func TestHasBlockReturnsNil(t *testing.T) {
Brian Tiger Chow's avatar
Brian Tiger Chow committed
22
	off := Exchange()
23
	block := blocks.NewBlock([]byte("data"))
Jeromy's avatar
Jeromy committed
24
	err := off.HasBlock(context.Background(), block)
25 26 27 28
	if err != nil {
		t.Fatal("")
	}
}