From 641fe42a1790309056644659d3973286f0deb093 Mon Sep 17 00:00:00 2001 From: 5kbpers Date: Wed, 6 Nov 2019 14:05:09 +0800 Subject: [PATCH] address comments Signed-off-by: 5kbpers --- server/api/admin_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/server/api/admin_test.go b/server/api/admin_test.go index a7963ac817d..bf9569199ed 100644 --- a/server/api/admin_test.go +++ b/server/api/admin_test.go @@ -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) { @@ -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, @@ -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, @@ -135,7 +135,7 @@ 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, @@ -143,8 +143,8 @@ func (s *testTSOSuite) TestResetTS(c *C) { 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,