Skip to content

Commit

Permalink
planner/core: migrate test-infra to testify for cache_test.go (#28415)
Browse files Browse the repository at this point in the history
  • Loading branch information
karuppiah7890 authored Sep 30, 2021
1 parent bba2848 commit 01908fc
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions planner/core/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,20 @@
package core

import (
"testing"
"time"

. "github.com/pingcap/check"
"github.com/pingcap/parser/mysql"
"github.com/pingcap/tidb/sessionctx"
"github.com/pingcap/tidb/util/testleak"
"github.com/stretchr/testify/require"
)

var _ = Suite(&testCacheSuite{})

type testCacheSuite struct {
ctx sessionctx.Context
}

func (s *testCacheSuite) SetUpSuite(c *C) {
func TestCacheKey(t *testing.T) {
t.Parallel()
ctx := MockContext()
ctx.GetSessionVars().SnapshotTS = 0
ctx.GetSessionVars().SQLMode = mysql.ModeNone
ctx.GetSessionVars().TimeZone = time.UTC
ctx.GetSessionVars().ConnectionID = 0
s.ctx = ctx
}

func (s *testCacheSuite) TestCacheKey(c *C) {
defer testleak.AfterTest(c)()
key := NewPSTMTPlanCacheKey(s.ctx.GetSessionVars(), 1, 1)
c.Assert(key.Hash(), DeepEquals, []byte{0x74, 0x65, 0x73, 0x74, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x74, 0x69, 0x64, 0x62, 0x74, 0x69, 0x6b, 0x76, 0x74, 0x69, 0x66, 0x6c, 0x61, 0x73, 0x68, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff})
key := NewPSTMTPlanCacheKey(ctx.GetSessionVars(), 1, 1)
require.Equal(t, []byte{0x74, 0x65, 0x73, 0x74, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x74, 0x69, 0x64, 0x62, 0x74, 0x69, 0x6b, 0x76, 0x74, 0x69, 0x66, 0x6c, 0x61, 0x73, 0x68, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, key.Hash())
}

0 comments on commit 01908fc

Please sign in to comment.