github.com/dolthub/go-mysql-server@v0.18.0/sql/mysql_db/tables_priv_test.go (about) 1 // Copyright 2022 Dolthub, 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 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package mysql_db 16 17 import "testing" 18 19 func TestTablesPrivTableSchema(t *testing.T) { 20 // Each column has a constant index that it expects to match, therefore if a column's position is updated and the 21 // variable referencing it hasn't also been updated, this will throw a panic. 22 for i, col := range tablesPrivTblSchema { 23 switch col.Name { 24 case "Host": 25 if tablesPrivTblColIndex_Host != i { 26 t.FailNow() 27 } 28 case "Db": 29 if tablesPrivTblColIndex_Db != i { 30 t.FailNow() 31 } 32 case "User": 33 if tablesPrivTblColIndex_User != i { 34 t.FailNow() 35 } 36 case "Table_name": 37 if tablesPrivTblColIndex_Table_name != i { 38 t.FailNow() 39 } 40 case "Grantor": 41 if tablesPrivTblColIndex_Grantor != i { 42 t.FailNow() 43 } 44 case "Timestamp": 45 if tablesPrivTblColIndex_Timestamp != i { 46 t.FailNow() 47 } 48 case "Table_priv": 49 if tablesPrivTblColIndex_Table_priv != i { 50 t.FailNow() 51 } 52 case "Column_priv": 53 if tablesPrivTblColIndex_Column_priv != i { 54 t.FailNow() 55 } 56 default: 57 t.Errorf(`col "%s" does not have a constant`, col.Name) 58 } 59 } 60 }