Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
test: add unit test case for static_locator.go
Browse files Browse the repository at this point in the history
Signed-off-by: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
  • Loading branch information
Guangwen Feng committed Jun 2, 2020
1 parent 5981693 commit 3e51fda
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions dfget/locator/static_locator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,24 @@ func (s *StaticLocatorTestSuite) Test_Refresh(c *check.C) {
c.Assert(l.load(), check.Equals, -1)
}

func (s *StaticLocatorTestSuite) Test_String(c *check.C) {
cases := []struct {
locator *StaticLocator
expected string
}{
{createLocator("a:80=1"), "empty"},
{createLocator("a:80=1"), "empty"},
{createLocator("a:80=1"), "test-group:[a:80=1]"},
}
cases[0].locator.Group = nil
cases[1].locator.inc()
cases[1].locator.inc()

for _, v := range cases {
c.Assert(v.locator.String(), check.Equals, v.expected)
}
}

func create(ip string, port, weight int) *Supernode {
return &Supernode{
Schema: config.DefaultSupernodeSchema,
Expand Down

0 comments on commit 3e51fda

Please sign in to comment.