Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
Signed-off-by: 5kbpers <tangminghua@pingcap.com>
  • Loading branch information
5kbpers committed Nov 6, 2019
1 parent 8264591 commit 641fe42
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions server/api/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ type testTSOSuite struct {
urlPrefix string
}

func makeTS(offset time.Duration) int64 {
func makeTS(offset time.Duration) uint64 {
physical := time.Now().Add(offset).UnixNano() / int64(time.Millisecond)
return physical << 18
return uint64(physical << 18)
}

func (s *testTSOSuite) SetUpSuite(c *C) {
Expand All @@ -115,7 +115,7 @@ func (s *testTSOSuite) TestResetTS(c *C) {
args := make(map[string]interface{})
t1 := makeTS(time.Hour)
url := s.urlPrefix
args["tso"] = fmt.Sprintf("%d", uint64(t1))
args["tso"] = fmt.Sprintf("%d", t1)
values, err := json.Marshal(args)
c.Assert(err, IsNil)
err = postJSON(url, values,
Expand All @@ -126,7 +126,7 @@ func (s *testTSOSuite) TestResetTS(c *C) {

c.Assert(err, IsNil)
t2 := makeTS(32 * time.Hour)
args["tso"] = fmt.Sprintf("%d", uint64(t2))
args["tso"] = fmt.Sprintf("%d", t2)
values, err = json.Marshal(args)
c.Assert(err, IsNil)
err = postJSON(url, values,
Expand All @@ -135,16 +135,16 @@ func (s *testTSOSuite) TestResetTS(c *C) {
c.Assert(strings.Contains(err.Error(), "too large"), IsTrue)

t3 := makeTS(-2 * time.Hour)
args["tso"] = fmt.Sprintf("%d", uint64(t3))
args["tso"] = fmt.Sprintf("%d", t3)
values, err = json.Marshal(args)
c.Assert(err, IsNil)
err = postJSON(url, values,
func(_ []byte, code int) { c.Assert(code, Equals, http.StatusForbidden) })
c.Assert(err, NotNil)
c.Assert(strings.Contains(err.Error(), "small"), IsTrue)

t4 := math.MinInt64
args["tso"] = fmt.Sprintf("%d", uint64(t4))
t4 := uint64(math.MinInt64)
args["tso"] = fmt.Sprintf("%d", t4)
values, err = json.Marshal(args)
c.Assert(err, IsNil)
err = postJSON(url, values,
Expand Down

0 comments on commit 641fe42

Please sign in to comment.