github.com/dolthub/go-mysql-server@v0.18.0/sql/mysql_db/role_edges_table_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 ( 18 "testing" 19 ) 20 21 func TestRoleEdgesTableSchema(t *testing.T) { 22 // Each column has a constant index that it expects to match, therefore if a column's position is updated and the 23 // variable referencing it hasn't also been updated, this will throw a panic. 24 for i, col := range roleEdgesTblSchema { 25 switch col.Name { 26 case "FROM_HOST": 27 if roleEdgesTblColIndex_FROM_HOST != i { 28 t.FailNow() 29 } 30 case "FROM_USER": 31 if roleEdgesTblColIndex_FROM_USER != i { 32 t.FailNow() 33 } 34 case "TO_HOST": 35 if roleEdgesTblColIndex_TO_HOST != i { 36 t.FailNow() 37 } 38 case "TO_USER": 39 if roleEdgesTblColIndex_TO_USER != i { 40 t.FailNow() 41 } 42 case "WITH_ADMIN_OPTION": 43 if roleEdgesTblColIndex_WITH_ADMIN_OPTION != i { 44 t.FailNow() 45 } 46 default: 47 t.Errorf(`col "%s" does not have a constant`, col.Name) 48 } 49 } 50 }