github.com/whtcorpsinc/milevadb-prod@v0.0.0-20211104133533-f57f4be3b597/causetstore/petri/acyclic/causet/embedded/cache_test.go (about) 1 // Copyright 2020 WHTCORPS INC, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // // Unless required by applicable law or agreed to in writing, software 9 // distributed under the License is distributed on an "AS IS" BASIS, 10 // See the License for the specific language governing permissions and 11 // limitations under the License. 12 13 package embedded 14 15 import ( 16 "time" 17 18 "github.com/whtcorpsinc/BerolinaSQL/allegrosql" 19 . "github.com/whtcorpsinc/check" 20 "github.com/whtcorpsinc/milevadb/soliton/testleak" 21 "github.com/whtcorpsinc/milevadb/stochastikctx" 22 ) 23 24 var _ = Suite(&testCacheSuite{}) 25 26 type testCacheSuite struct { 27 ctx stochastikctx.Context 28 } 29 30 func (s *testCacheSuite) SetUpSuite(c *C) { 31 ctx := MockContext() 32 ctx.GetStochastikVars().SnapshotTS = 0 33 ctx.GetStochastikVars().ALLEGROSQLMode = allegrosql.ModeNone 34 ctx.GetStochastikVars().TimeZone = time.UTC 35 ctx.GetStochastikVars().ConnectionID = 0 36 s.ctx = ctx 37 } 38 39 func (s *testCacheSuite) TestCacheKey(c *C) { 40 defer testleak.AfterTest(c)() 41 key := NewPSTMTCausetCacheKey(s.ctx.GetStochastikVars(), 1, 1) 42 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, 0x0, 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}) 43 }