providers_test.go 582 Bytes
Newer Older
1 2 3 4 5 6 7
package dht

import (
	"testing"

	"github.com/jbenet/go-ipfs/peer"
	u "github.com/jbenet/go-ipfs/util"
8
	testutil "github.com/jbenet/go-ipfs/util/testutil"
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
9 10

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

func TestProviderManager(t *testing.T) {
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
14
	ctx := context.Background()
15
	mid := peer.ID("testing")
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
16
	p := NewProviderManager(ctx, mid)
17
	a := u.Key("test")
18
	p.AddProvider(a, testutil.NewPeerWithIDString("testingprovider"))
19
	resp := p.GetProviders(ctx, a)
20 21 22
	if len(resp) != 1 {
		t.Fatal("Could not retrieve provider.")
	}
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
23
	p.Close()
24
}