2014-09-04 20:32:46 +00:00
|
|
|
package dht
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2014-12-19 12:19:56 -08:00
|
|
|
peer "github.com/jbenet/go-ipfs/peer"
|
2014-09-04 20:32:46 +00:00
|
|
|
u "github.com/jbenet/go-ipfs/util"
|
2014-10-25 07:12:01 -07:00
|
|
|
|
|
|
|
context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
|
2014-09-04 20:32:46 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestProviderManager(t *testing.T) {
|
2014-10-25 07:12:01 -07:00
|
|
|
ctx := context.Background()
|
2014-09-04 20:32:46 +00:00
|
|
|
mid := peer.ID("testing")
|
2014-10-25 07:12:01 -07:00
|
|
|
p := NewProviderManager(ctx, mid)
|
2014-09-04 20:32:46 +00:00
|
|
|
a := u.Key("test")
|
2014-12-19 12:19:56 -08:00
|
|
|
p.AddProvider(a, peer.ID("testingprovider"))
|
2014-12-02 00:40:50 -08:00
|
|
|
resp := p.GetProviders(ctx, a)
|
2014-09-04 20:32:46 +00:00
|
|
|
if len(resp) != 1 {
|
|
|
|
t.Fatal("Could not retrieve provider.")
|
|
|
|
}
|
2014-10-25 07:12:01 -07:00
|
|
|
p.Close()
|
2014-09-04 20:32:46 +00:00
|
|
|
}
|