@@ -27,6 +27,28 @@ func TestUsageParams_SetDefaults(t *testing.T) {
2727 WindowType : & []WindowType {SlidingWindow }[0 ],
2828 },
2929 },
30+ {
31+ name : "negative half life period should be disabled" ,
32+ input : & UsageParams {
33+ HalfLifePeriod : & metav1.Duration {Duration : - 3 * time .Minute },
34+ },
35+ expected : & UsageParams {
36+ HalfLifePeriod : nil ,
37+ WindowSize : & metav1.Duration {Duration : time .Hour * 24 * 7 },
38+ WindowType : & []WindowType {SlidingWindow }[0 ],
39+ },
40+ },
41+ {
42+ name : "zero half life period should be disabled" ,
43+ input : & UsageParams {
44+ HalfLifePeriod : & metav1.Duration {Duration : 0 * time .Minute },
45+ },
46+ expected : & UsageParams {
47+ HalfLifePeriod : nil ,
48+ WindowSize : & metav1.Duration {Duration : time .Hour * 24 * 7 },
49+ WindowType : & []WindowType {SlidingWindow }[0 ],
50+ },
51+ },
3052 {
3153 name : "params with half life set should preserve it" ,
3254 input : & UsageParams {
@@ -290,10 +312,9 @@ func TestUsageParams_ZeroValues(t *testing.T) {
290312
291313 params .SetDefaults ()
292314
293- // Zero values should be preserved, not replaced with defaults
294- require .NotNil (t , params .HalfLifePeriod )
295- assert .Equal (t , time .Duration (0 ), params .HalfLifePeriod .Duration )
315+ require .Nil (t , params .HalfLifePeriod )
296316
317+ // Zero values should be preserved, not replaced with defaults
297318 require .NotNil (t , params .WindowSize )
298319 assert .Equal (t , time .Duration (0 ), params .WindowSize .Duration )
299320
0 commit comments