@@ -1173,6 +1173,44 @@ func TestTableColumnCountLimit(t *testing.T) {
1173
1173
checkValid (DefMaxOfTableColumnCountLimit + 1 , false )
1174
1174
}
1175
1175
1176
+ func TestTokenLimit (t * testing.T ) {
1177
+ storeDir := t .TempDir ()
1178
+ configFile := filepath .Join (storeDir , "config.toml" )
1179
+ f , err := os .Create (configFile )
1180
+ require .NoError (t , err )
1181
+ defer func (configFile string ) {
1182
+ require .NoError (t , os .Remove (configFile ))
1183
+ }(configFile )
1184
+
1185
+ tests := []struct {
1186
+ tokenLimit uint
1187
+ expectedTokenLimit uint
1188
+ }{
1189
+ {
1190
+ 0 ,
1191
+ 1000 ,
1192
+ },
1193
+ {
1194
+ 99999999999 ,
1195
+ MaxTokenLimit ,
1196
+ },
1197
+ }
1198
+
1199
+ for _ , test := range tests {
1200
+ require .NoError (t , f .Truncate (0 ))
1201
+ _ , err = f .Seek (0 , 0 )
1202
+ require .NoError (t , err )
1203
+ _ , err = f .WriteString (fmt .Sprintf (`
1204
+ token-limit = %d
1205
+ ` , test .tokenLimit ))
1206
+ require .NoError (t , err )
1207
+ require .NoError (t , f .Sync ())
1208
+ conf := NewConfig ()
1209
+ require .NoError (t , conf .Load (configFile ))
1210
+ require .Equal (t , test .expectedTokenLimit , conf .TokenLimit )
1211
+ }
1212
+ }
1213
+
1176
1214
func TestEncodeDefTempStorageDir (t * testing.T ) {
1177
1215
tests := []struct {
1178
1216
host string
0 commit comments