github.com/whtcorpsinc/MilevaDB-Prod@v0.0.0-20211104133533-f57f4be3b597/causetstore/petri/acyclic/causet/implementation/base_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  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // See the License for the specific language governing permissions and
    12  // limitations under the License.
    13  
    14  package implementation
    15  
    16  import (
    17  	"testing"
    18  
    19  	"github.com/whtcorpsinc/BerolinaSQL"
    20  	"github.com/whtcorpsinc/BerolinaSQL/perceptron"
    21  	. "github.com/whtcorpsinc/check"
    22  	causetembedded "github.com/whtcorpsinc/milevadb/causet/embedded"
    23  	"github.com/whtcorpsinc/milevadb/causet/memo"
    24  	"github.com/whtcorpsinc/milevadb/schemareplicant"
    25  	"github.com/whtcorpsinc/milevadb/soliton/testleak"
    26  	"github.com/whtcorpsinc/milevadb/stochastikctx"
    27  )
    28  
    29  func TestT(t *testing.T) {
    30  	CustomVerboseFlag = true
    31  	TestingT(t)
    32  }
    33  
    34  var _ = Suite(&testImplSuite{})
    35  
    36  type testImplSuite struct {
    37  	*BerolinaSQL.BerolinaSQL
    38  	is   schemareplicant.SchemaReplicant
    39  	sctx stochastikctx.Context
    40  }
    41  
    42  func (s *testImplSuite) SetUpSuite(c *C) {
    43  	testleak.BeforeTest()
    44  	s.is = schemareplicant.MockSchemaReplicant([]*perceptron.BlockInfo{causetembedded.MockSignedBlock()})
    45  	s.sctx = causetembedded.MockContext()
    46  	s.BerolinaSQL = BerolinaSQL.New()
    47  }
    48  
    49  func (s *testImplSuite) TearDownSuite(c *C) {
    50  	testleak.AfterTest(c)()
    51  }
    52  
    53  func (s *testImplSuite) TestBaseImplementation(c *C) {
    54  	p := causetembedded.PhysicalLimit{}.Init(s.sctx, nil, 0, nil)
    55  	impl := &baseImpl{plan: p}
    56  	c.Assert(impl.GetCauset(), Equals, p)
    57  
    58  	cost := impl.CalcCost(10, []memo.Implementation{}...)
    59  	c.Assert(cost, Equals, 0.0)
    60  	c.Assert(impl.GetCost(), Equals, 0.0)
    61  
    62  	impl.SetCost(6.0)
    63  	c.Assert(impl.GetCost(), Equals, 6.0)
    64  }