Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1194 from fenggw-fnst/work2
Browse files Browse the repository at this point in the history
test: add unit test case for func GetAllPeerIDs
  • Loading branch information
allencloud authored Feb 17, 2020
2 parents a88b5f0 + d1fbbd3 commit caad9fd
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions supernode/daemon/mgr/peer/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package peer

import (
"context"
"sort"
"testing"
"time"

Expand Down Expand Up @@ -127,6 +128,37 @@ func (s *PeerMgrTestSuite) TestGet(c *check.C) {
c.Check(info, check.DeepEquals, expected)
}

func (s *PeerMgrTestSuite) TestGetAllPeerIDs(c *check.C) {
manager, _ := NewManager(prometheus.NewRegistry())

// the first data
request := &types.PeerCreateRequest{
IP: "192.168.10.11",
HostName: "foo",
Port: 65001,
Version: version.DFGetVersion,
}
resp, err := manager.Register(context.Background(), request)
c.Check(err, check.IsNil)
id := resp.ID

// the second data
request = &types.PeerCreateRequest{
IP: "192.168.10.11",
HostName: "bar",
Port: 65001,
Version: version.DFGetVersion,
}
resp, err = manager.Register(context.Background(), request)
c.Check(err, check.IsNil)
id2 := resp.ID

// get all peer ids
ids := manager.GetAllPeerIDs(context.Background())
sort.Strings(ids)
c.Check(ids, check.DeepEquals, []string{id2, id})
}

func (s *PeerMgrTestSuite) TestList(c *check.C) {
manager, _ := NewManager(prometheus.NewRegistry())
// the first data
Expand Down

0 comments on commit caad9fd

Please sign in to comment.