Skip to content

Commit

Permalink
refactor: clearer MakeAPI*
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentsenta committed May 2, 2023
1 parent f2e8db2 commit ee04895
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions coreiface/tests/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ func (tp *TestSuite) makeAPI(ctx context.Context) (coreiface.CoreAPI, error) {
return api[0], nil
}

func (tp *TestSuite) MakeAPISwarm(ctx context.Context, fullIdentity bool, n int) ([]coreiface.CoreAPI, error) {
return tp.makeAPISwarm(ctx, fullIdentity, fullIdentity, n)
}

func (tp *TestSuite) makeAPIWithIdentityAndOffline(ctx context.Context) (coreiface.CoreAPI, error) {
api, err := tp.makeAPISwarm(ctx, true, false, 1)
if err != nil {
Expand All @@ -50,6 +46,10 @@ func (tp *TestSuite) makeAPIWithIdentityAndOffline(ctx context.Context) (coreifa
return api[0], nil
}

func (tp *TestSuite) MakeAPISwarm(ctx context.Context, n int) ([]coreiface.CoreAPI, error) {
return tp.makeAPISwarm(ctx, true, true, n)
}

type TestSuite struct {
Provider

Expand Down
6 changes: 3 additions & 3 deletions coreiface/tests/dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (tp *TestSuite) TestDht(t *testing.T) {
func (tp *TestSuite) TestDhtFindPeer(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
apis, err := tp.MakeAPISwarm(ctx, true, 5)
apis, err := tp.MakeAPISwarm(ctx, 5)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -81,7 +81,7 @@ func (tp *TestSuite) TestDhtFindPeer(t *testing.T) {
func (tp *TestSuite) TestDhtFindProviders(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
apis, err := tp.MakeAPISwarm(ctx, true, 5)
apis, err := tp.MakeAPISwarm(ctx, 5)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -113,7 +113,7 @@ func (tp *TestSuite) TestDhtFindProviders(t *testing.T) {
func (tp *TestSuite) TestDhtProvide(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
apis, err := tp.MakeAPISwarm(ctx, true, 5)
apis, err := tp.MakeAPISwarm(ctx, 5)
if err != nil {
t.Fatal(err)
}
Expand Down
6 changes: 3 additions & 3 deletions coreiface/tests/name.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (tp *TestSuite) TestPublishResolve(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
init := func() (coreiface.CoreAPI, path.Path) {
apis, err := tp.MakeAPISwarm(ctx, true, 5)
apis, err := tp.MakeAPISwarm(ctx, 5)
if err != nil {
t.Fatal(err)
return nil, nil
Expand Down Expand Up @@ -191,7 +191,7 @@ func (tp *TestSuite) TestPublishResolve(t *testing.T) {
func (tp *TestSuite) TestBasicPublishResolveKey(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
apis, err := tp.MakeAPISwarm(ctx, true, 5)
apis, err := tp.MakeAPISwarm(ctx, 5)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -235,7 +235,7 @@ func (tp *TestSuite) TestBasicPublishResolveTimeout(t *testing.T) {

ctx, cancel := context.WithCancel(context.Background())
defer cancel()
apis, err := tp.MakeAPISwarm(ctx, true, 5)
apis, err := tp.MakeAPISwarm(ctx, 5)
if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion coreiface/tests/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (tp *TestSuite) TestBasicPubSub(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

apis, err := tp.MakeAPISwarm(ctx, true, 2)
apis, err := tp.MakeAPISwarm(ctx, 2)
if err != nil {
t.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions coreiface/tests/routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (tp *TestSuite) TestRoutingGet(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

apis, err := tp.MakeAPISwarm(ctx, true, 2)
apis, err := tp.MakeAPISwarm(ctx, 2)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -77,7 +77,7 @@ func (tp *TestSuite) TestRoutingGet(t *testing.T) {
func (tp *TestSuite) TestRoutingPut(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
apis, err := tp.MakeAPISwarm(ctx, true, 2)
apis, err := tp.MakeAPISwarm(ctx, 2)
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit ee04895

Please sign in to comment.