@@ -154,10 +154,13 @@ func TestBuildRegistryConfig(t *testing.T) {
154154 apiConfig : nil ,
155155 assertion : func (t * testing.T , cfg * registry.Config ) {
156156 assert .Equal (t , uint64 (0 ), cfg .MaxBytes , "Default global limit should be 0 (unlimited)" )
157+ assert .Equal (t , uint64 (0 ), cfg .MaxRequests , "Default global request limit should be 0 (unlimited)" )
157158 require .NotNil (t , cfg .DefaultPriorityBand ,
158159 "Default priority band template should be initialized automatically" )
159160 assert .Equal (t , uint64 (1_000_000_000 ) /* registry default: 1 GB */ , cfg .DefaultPriorityBand .MaxBytes ,
160161 "Default template should use system default capacity" )
162+ assert .Equal (t , uint64 (5000 ) /* registry default */ , cfg .DefaultPriorityBand .MaxRequests ,
163+ "Default template should use the system default request-count capacity" )
161164 },
162165 },
163166
@@ -207,6 +210,49 @@ func TestBuildRegistryConfig(t *testing.T) {
207210 "Explicit 0 in DefaultPriorityBand template should be treated as 'Use Default'" )
208211 },
209212 },
213+ {
214+ name : "ShouldApplyDefault_WhenBandMaxRequestsIsNilOrZero" ,
215+ apiConfig : & configapi.FlowControlConfig {
216+ PriorityBands : []configapi.PriorityBandConfig {
217+ {
218+ Priority : 1 ,
219+ // MaxRequests omitted
220+ },
221+ {
222+ Priority : 2 ,
223+ MaxRequests : ptr .To (resource .MustParse ("0" )), // Explicitly zero
224+ },
225+ {
226+ Priority : 3 ,
227+ MaxRequests : ptr .To (resource .MustParse ("250" )),
228+ },
229+ },
230+ },
231+ assertion : func (t * testing.T , cfg * registry.Config ) {
232+ require .Contains (t , cfg .PriorityBands , 1 )
233+ assert .Equal (t , uint64 (5000 ) /* registry default */ , cfg .PriorityBands [1 ].MaxRequests ,
234+ "Omitted MaxRequests (nil) should result in the system default (5000)" )
235+ require .Contains (t , cfg .PriorityBands , 2 )
236+ assert .Equal (t , uint64 (5000 ) /* registry default */ , cfg .PriorityBands [2 ].MaxRequests ,
237+ "Explicit MaxRequests (0) should be treated as 'Use Default' (5000)" )
238+ require .Contains (t , cfg .PriorityBands , 3 )
239+ assert .Equal (t , uint64 (250 ), cfg .PriorityBands [3 ].MaxRequests ,
240+ "Explicit MaxRequests should be preserved" )
241+ },
242+ },
243+ {
244+ name : "ShouldApplyDefault_WhenNegativeBandTemplateMaxRequestsIsZero" ,
245+ apiConfig : & configapi.FlowControlConfig {
246+ DefaultNegativePriorityBand : & configapi.PriorityBandConfig {
247+ MaxRequests : ptr .To (resource .MustParse ("0" )), // Explicitly zero
248+ },
249+ },
250+ assertion : func (t * testing.T , cfg * registry.Config ) {
251+ require .NotNil (t , cfg .DefaultNegativePriorityBand )
252+ assert .Equal (t , uint64 (5000 ) /* registry default */ , cfg .DefaultNegativePriorityBand .MaxRequests ,
253+ "Explicit 0 in the negative band template should be treated as 'Use Default', not zero capacity" )
254+ },
255+ },
210256
211257 // --- Validation Errors ---
212258 {
@@ -299,37 +345,8 @@ func TestBuildRegistryConfig(t *testing.T) {
299345 },
300346
301347 // --- MaxRequests: Defaulting Logic ---
302- {
303- name : "ShouldDefaultToZero_WhenMaxRequestsIsNil" ,
304- apiConfig : & configapi.FlowControlConfig {
305- PriorityBands : []configapi.PriorityBandConfig {
306- {
307- Priority : 1 ,
308- },
309- },
310- },
311- assertion : func (t * testing.T , cfg * registry.Config ) {
312- require .Contains (t , cfg .PriorityBands , 1 )
313- assert .Equal (t , uint64 (0 ), cfg .PriorityBands [1 ].MaxRequests ,
314- "Omitted MaxRequests should default to 0 (no request limit)" )
315- },
316- },
317- {
318- name : "ShouldDefaultToZero_WhenMaxRequestsIsZero" ,
319- apiConfig : & configapi.FlowControlConfig {
320- PriorityBands : []configapi.PriorityBandConfig {
321- {
322- Priority : 1 ,
323- MaxRequests : ptr .To (resource .MustParse ("0" )),
324- },
325- },
326- },
327- assertion : func (t * testing.T , cfg * registry.Config ) {
328- require .Contains (t , cfg .PriorityBands , 1 )
329- assert .Equal (t , uint64 (0 ), cfg .PriorityBands [1 ].MaxRequests ,
330- "Explicit MaxRequests=0 should remain 0 (no request limit)" )
331- },
332- },
348+ // Nil and explicit-zero band MaxRequests defaulting is covered by
349+ // ShouldApplyDefault_WhenBandMaxRequestsIsNilOrZero above.
333350
334351 // --- MaxRequests: Validation Errors ---
335352 {
0 commit comments