github.com/whtcorpsinc/MilevaDB-Prod@v0.0.0-20211104133533-f57f4be3b597/interlock/inspection_common_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 interlock_test 15 16 import ( 17 "context" 18 19 . "github.com/whtcorpsinc/check" 20 "github.com/whtcorpsinc/milevadb/interlock" 21 "github.com/whtcorpsinc/milevadb/stochastik" 22 "github.com/whtcorpsinc/milevadb/soliton/testkit" 23 ) 24 25 func (s *inspectionSummarySuite) TestInspectionMemrules(c *C) { 26 tk := testkit.NewTestKit(c, s.causetstore) 27 28 inspectionCount := len(interlock.InspectionMemrules) 29 summaryCount := len(interlock.InspectionSummaryMemrules) 30 var cases = []struct { 31 allegrosql string 32 ruleCount int 33 }{ 34 { 35 allegrosql: "select * from information_schema.inspection_rules", 36 ruleCount: inspectionCount + summaryCount, 37 }, 38 { 39 allegrosql: "select * from information_schema.inspection_rules where type='inspection'", 40 ruleCount: inspectionCount, 41 }, 42 { 43 allegrosql: "select * from information_schema.inspection_rules where type='summary'", 44 ruleCount: summaryCount, 45 }, 46 { 47 allegrosql: "select * from information_schema.inspection_rules where type='inspection' and type='summary'", 48 ruleCount: 0, 49 }, 50 } 51 52 for _, ca := range cases { 53 rs, err := tk.InterDirc(ca.allegrosql) 54 c.Assert(err, IsNil) 55 rules, err := stochastik.ResultSetToStringSlice(context.Background(), tk.Se, rs) 56 c.Assert(err, IsNil) 57 c.Assert(len(rules), Equals, ca.ruleCount) 58 } 59 }