Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use validator in SearchValue #9

Merged
merged 5 commits into from
Sep 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 83 additions & 70 deletions bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"testing"

errwrap "github.com/hashicorp/errwrap"
routing "github.com/libp2p/go-libp2p-routing"
)

type bootstrapRouter struct {
Expand All @@ -20,57 +21,63 @@ func (bs *bootstrapRouter) Bootstrap(ctx context.Context) error {
func TestBootstrap(t *testing.T) {
pings := make([]bool, 6)
d := Parallel{
Tiered{
&bootstrapRouter{
bs: func() error {
pings[0] = true
return nil
Routers: []routing.IpfsRouting{
Tiered{
Routers: []routing.IpfsRouting{
&bootstrapRouter{
bs: func() error {
pings[0] = true
return nil
},
},
},
},
},
Tiered{
&bootstrapRouter{
bs: func() error {
pings[1] = true
return nil
Tiered{
Routers: []routing.IpfsRouting{
&bootstrapRouter{
bs: func() error {
pings[1] = true
return nil
},
},
&bootstrapRouter{
bs: func() error {
pings[2] = true
return nil
},
},
},
},
&bootstrapRouter{
bs: func() error {
pings[2] = true
return nil
&Compose{
ValueStore: &LimitedValueStore{
ValueStore: &bootstrapRouter{
bs: func() error {
pings[3] = true
return nil
},
},
Namespaces: []string{"allow1", "allow2", "notsupported", "error"},
},
},
},
&Compose{
ValueStore: &LimitedValueStore{
ValueStore: &bootstrapRouter{
&Compose{
ValueStore: &LimitedValueStore{
ValueStore: &dummyValueStore{},
},
},
Null{},
&Compose{},
&Compose{
ContentRouting: &bootstrapRouter{
bs: func() error {
pings[3] = true
pings[4] = true
return nil
},
},
Namespaces: []string{"allow1", "allow2", "notsupported", "error"},
},
},
&Compose{
ValueStore: &LimitedValueStore{
ValueStore: &dummyValueStore{},
},
},
Null{},
&Compose{},
&Compose{
ContentRouting: &bootstrapRouter{
bs: func() error {
pings[4] = true
return nil
},
},
PeerRouting: &bootstrapRouter{
bs: func() error {
pings[5] = true
return nil
PeerRouting: &bootstrapRouter{
bs: func() error {
pings[5] = true
return nil
},
},
},
},
Expand All @@ -88,48 +95,54 @@ func TestBootstrap(t *testing.T) {
}
func TestBootstrapErr(t *testing.T) {
d := Parallel{
Tiered{
&bootstrapRouter{
bs: func() error {
return errors.New("err1")
Routers: []routing.IpfsRouting{
Tiered{
Routers: []routing.IpfsRouting{
&bootstrapRouter{
bs: func() error {
return errors.New("err1")
},
},
},
},
},
Tiered{
&bootstrapRouter{
bs: func() error {
return nil
Tiered{
Routers: []routing.IpfsRouting{
&bootstrapRouter{
bs: func() error {
return nil
},
},
&bootstrapRouter{
bs: func() error {
return nil
},
},
},
},
&bootstrapRouter{
bs: func() error {
return nil
&Compose{
ValueStore: &LimitedValueStore{
ValueStore: &bootstrapRouter{
bs: func() error {
return errors.New("err2")
},
},
Namespaces: []string{"allow1", "allow2", "notsupported", "error"},
},
},
},
&Compose{
ValueStore: &LimitedValueStore{
&Compose{
ValueStore: &bootstrapRouter{
bs: func() error {
return errors.New("err2")
return errors.New("err3")
},
},
Namespaces: []string{"allow1", "allow2", "notsupported", "error"},
},
},
&Compose{
ValueStore: &bootstrapRouter{
bs: func() error {
return errors.New("err3")
},
},
ContentRouting: &bootstrapRouter{
bs: func() error {
return errors.New("err4")
ContentRouting: &bootstrapRouter{
bs: func() error {
return errors.New("err4")
},
},
},
Null{},
},
Null{},
}
ctx := context.Background()
err := d.Bootstrap(ctx)
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
"hash": "QmfGQp6VVqdPCDyzEM6EGwMY74YPabTSEoQWHUxZuCSWj3",
"name": "go-multierror",
"version": "0.1.0"
},
{
"hash": "QmSb4B8ZAAj5ALe9LjfzPyF8Ma6ezC1NTnDF2JQPUJxEXb",
"name": "go-libp2p-record",
"version": "4.1.7"
}
],
"gxVersion": "0.12.1",
Expand Down
Loading