@@ -187,6 +187,11 @@ func TestConfig_Load(t *testing.T) {
187
187
},
188
188
},
189
189
Job : JobConfig {
190
+ RateLimit : RateLimitConfig {
191
+ FillInterval : 1 * time .Second ,
192
+ Capacity : 1000 ,
193
+ Quantum : 1000 ,
194
+ },
190
195
Preheat : PreheatConfig {
191
196
RegistryTimeout : DefaultJobPreheatRegistryTimeout ,
192
197
TLS : & PreheatTLSClientConfig {
@@ -697,6 +702,51 @@ func TestConfig_Validate(t *testing.T) {
697
702
assert .EqualError (err , "local requires parameter ttl" )
698
703
},
699
704
},
705
+ {
706
+ name : "rateLimit requires parameter fillInterval" ,
707
+ config : New (),
708
+ mock : func (cfg * Config ) {
709
+ cfg .Auth .JWT = mockJWTConfig
710
+ cfg .Database .Type = DatabaseTypeMysql
711
+ cfg .Database .Mysql = mockMysqlConfig
712
+ cfg .Database .Redis = mockRedisConfig
713
+ cfg .Job .RateLimit .FillInterval = 0
714
+ },
715
+ expect : func (t * testing.T , err error ) {
716
+ assert := assert .New (t )
717
+ assert .EqualError (err , "rateLimit requires parameter fillInterval" )
718
+ },
719
+ },
720
+ {
721
+ name : "rateLimit requires parameter capacity" ,
722
+ config : New (),
723
+ mock : func (cfg * Config ) {
724
+ cfg .Auth .JWT = mockJWTConfig
725
+ cfg .Database .Type = DatabaseTypeMysql
726
+ cfg .Database .Mysql = mockMysqlConfig
727
+ cfg .Database .Redis = mockRedisConfig
728
+ cfg .Job .RateLimit .Capacity = 0
729
+ },
730
+ expect : func (t * testing.T , err error ) {
731
+ assert := assert .New (t )
732
+ assert .EqualError (err , "rateLimit requires parameter capacity" )
733
+ },
734
+ },
735
+ {
736
+ name : "rateLimit requires parameter quantum" ,
737
+ config : New (),
738
+ mock : func (cfg * Config ) {
739
+ cfg .Auth .JWT = mockJWTConfig
740
+ cfg .Database .Type = DatabaseTypeMysql
741
+ cfg .Database .Mysql = mockMysqlConfig
742
+ cfg .Database .Redis = mockRedisConfig
743
+ cfg .Job .RateLimit .Quantum = 0
744
+ },
745
+ expect : func (t * testing.T , err error ) {
746
+ assert := assert .New (t )
747
+ assert .EqualError (err , "rateLimit requires parameter quantum" )
748
+ },
749
+ },
700
750
{
701
751
name : "preheat requires parameter caCert" ,
702
752
config : New (),
0 commit comments