github.com/dolthub/go-mysql-server@v0.18.0/sql/mysql_db/user_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 TestUserTableSchema(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 userTblSchema {
    25  		switch col.Name {
    26  		case "Host":
    27  			if userTblColIndex_Host != i {
    28  				t.FailNow()
    29  			}
    30  		case "User":
    31  			if userTblColIndex_User != i {
    32  				t.FailNow()
    33  			}
    34  		case "Select_priv":
    35  			if userTblColIndex_Select_priv != i {
    36  				t.FailNow()
    37  			}
    38  		case "Insert_priv":
    39  			if userTblColIndex_Insert_priv != i {
    40  				t.FailNow()
    41  			}
    42  		case "Update_priv":
    43  			if userTblColIndex_Update_priv != i {
    44  				t.FailNow()
    45  			}
    46  		case "Delete_priv":
    47  			if userTblColIndex_Delete_priv != i {
    48  				t.FailNow()
    49  			}
    50  		case "Create_priv":
    51  			if userTblColIndex_Create_priv != i {
    52  				t.FailNow()
    53  			}
    54  		case "Drop_priv":
    55  			if userTblColIndex_Drop_priv != i {
    56  				t.FailNow()
    57  			}
    58  		case "Reload_priv":
    59  			if userTblColIndex_Reload_priv != i {
    60  				t.FailNow()
    61  			}
    62  		case "Shutdown_priv":
    63  			if userTblColIndex_Shutdown_priv != i {
    64  				t.FailNow()
    65  			}
    66  		case "Process_priv":
    67  			if userTblColIndex_Process_priv != i {
    68  				t.FailNow()
    69  			}
    70  		case "File_priv":
    71  			if userTblColIndex_File_priv != i {
    72  				t.FailNow()
    73  			}
    74  		case "Grant_priv":
    75  			if userTblColIndex_Grant_priv != i {
    76  				t.FailNow()
    77  			}
    78  		case "References_priv":
    79  			if userTblColIndex_References_priv != i {
    80  				t.FailNow()
    81  			}
    82  		case "Index_priv":
    83  			if userTblColIndex_Index_priv != i {
    84  				t.FailNow()
    85  			}
    86  		case "Alter_priv":
    87  			if userTblColIndex_Alter_priv != i {
    88  				t.FailNow()
    89  			}
    90  		case "Show_db_priv":
    91  			if userTblColIndex_Show_db_priv != i {
    92  				t.FailNow()
    93  			}
    94  		case "Super_priv":
    95  			if userTblColIndex_Super_priv != i {
    96  				t.FailNow()
    97  			}
    98  		case "Create_tmp_table_priv":
    99  			if userTblColIndex_Create_tmp_table_priv != i {
   100  				t.FailNow()
   101  			}
   102  		case "Lock_tables_priv":
   103  			if userTblColIndex_Lock_tables_priv != i {
   104  				t.FailNow()
   105  			}
   106  		case "Execute_priv":
   107  			if userTblColIndex_Execute_priv != i {
   108  				t.FailNow()
   109  			}
   110  		case "Repl_slave_priv":
   111  			if userTblColIndex_Repl_slave_priv != i {
   112  				t.FailNow()
   113  			}
   114  		case "Repl_client_priv":
   115  			if userTblColIndex_Repl_client_priv != i {
   116  				t.FailNow()
   117  			}
   118  		case "Create_view_priv":
   119  			if userTblColIndex_Create_view_priv != i {
   120  				t.FailNow()
   121  			}
   122  		case "Show_view_priv":
   123  			if userTblColIndex_Show_view_priv != i {
   124  				t.FailNow()
   125  			}
   126  		case "Create_routine_priv":
   127  			if userTblColIndex_Create_routine_priv != i {
   128  				t.FailNow()
   129  			}
   130  		case "Alter_routine_priv":
   131  			if userTblColIndex_Alter_routine_priv != i {
   132  				t.FailNow()
   133  			}
   134  		case "Create_user_priv":
   135  			if userTblColIndex_Create_user_priv != i {
   136  				t.FailNow()
   137  			}
   138  		case "Event_priv":
   139  			if userTblColIndex_Event_priv != i {
   140  				t.FailNow()
   141  			}
   142  		case "Trigger_priv":
   143  			if userTblColIndex_Trigger_priv != i {
   144  				t.FailNow()
   145  			}
   146  		case "Create_tablespace_priv":
   147  			if userTblColIndex_Create_tablespace_priv != i {
   148  				t.FailNow()
   149  			}
   150  		case "ssl_type":
   151  			if userTblColIndex_ssl_type != i {
   152  				t.FailNow()
   153  			}
   154  		case "ssl_cipher":
   155  			if userTblColIndex_ssl_cipher != i {
   156  				t.FailNow()
   157  			}
   158  		case "x509_issuer":
   159  			if userTblColIndex_x509_issuer != i {
   160  				t.FailNow()
   161  			}
   162  		case "x509_subject":
   163  			if userTblColIndex_x509_subject != i {
   164  				t.FailNow()
   165  			}
   166  		case "max_questions":
   167  			if userTblColIndex_max_questions != i {
   168  				t.FailNow()
   169  			}
   170  		case "max_updates":
   171  			if userTblColIndex_max_updates != i {
   172  				t.FailNow()
   173  			}
   174  		case "max_connections":
   175  			if userTblColIndex_max_connections != i {
   176  				t.FailNow()
   177  			}
   178  		case "max_user_connections":
   179  			if userTblColIndex_max_user_connections != i {
   180  				t.FailNow()
   181  			}
   182  		case "plugin":
   183  			if userTblColIndex_plugin != i {
   184  				t.FailNow()
   185  			}
   186  		case "authentication_string":
   187  			if userTblColIndex_authentication_string != i {
   188  				t.FailNow()
   189  			}
   190  		case "password_expired":
   191  			if userTblColIndex_password_expired != i {
   192  				t.FailNow()
   193  			}
   194  		case "password_last_changed":
   195  			if userTblColIndex_password_last_changed != i {
   196  				t.FailNow()
   197  			}
   198  		case "password_lifetime":
   199  			if userTblColIndex_password_lifetime != i {
   200  				t.FailNow()
   201  			}
   202  		case "account_locked":
   203  			if userTblColIndex_account_locked != i {
   204  				t.FailNow()
   205  			}
   206  		case "Create_role_priv":
   207  			if userTblColIndex_Create_role_priv != i {
   208  				t.FailNow()
   209  			}
   210  		case "Drop_role_priv":
   211  			if userTblColIndex_Drop_role_priv != i {
   212  				t.FailNow()
   213  			}
   214  		case "Password_reuse_history":
   215  			if userTblColIndex_Password_reuse_history != i {
   216  				t.FailNow()
   217  			}
   218  		case "Password_reuse_time":
   219  			if userTblColIndex_Password_reuse_time != i {
   220  				t.FailNow()
   221  			}
   222  		case "Password_require_current":
   223  			if userTblColIndex_Password_require_current != i {
   224  				t.FailNow()
   225  			}
   226  		case "User_attributes":
   227  			if userTblColIndex_User_attributes != i {
   228  				t.FailNow()
   229  			}
   230  		case "identity":
   231  			if userTblColIndex_identity != i {
   232  				t.FailNow()
   233  			}
   234  		default:
   235  			t.Errorf(`col "%s" does not have a constant`, col.Name)
   236  		}
   237  	}
   238  }