@@ -89,12 +89,12 @@ func TestValidation_SaveAll_EmptySettings(t *testing.T) {
8989 t .Fatalf ("GetAll failed: %v" , err )
9090 }
9191
92- // SaveAll preserves explicitly empty plaintext values.
93- if loaded .AIMode != "" {
94- t .Errorf ("aiMode = %q, want empty string " , loaded .AIMode )
92+ // Empty fields should get defaults
93+ if loaded .AIMode != "medium " {
94+ t .Errorf ("aiMode = %q, want default %q " , loaded .AIMode , "medium" )
9595 }
96- if loaded .Theme != "" {
97- t .Errorf ("theme = %q, want empty string " , loaded .Theme )
96+ if loaded .Theme != "kubestellar " {
97+ t .Errorf ("theme = %q, want default %q " , loaded .Theme , "kubestellar" )
9898 }
9999}
100100
@@ -153,9 +153,20 @@ func TestValidation_SaveAll_PredictionThresholds(t *testing.T) {
153153 t .Fatalf ("GetAll failed: %v" , err )
154154 }
155155
156- // SaveAll persists the provided threshold struct as-is.
157- if loaded .Predictions .Thresholds != tc .thresholds {
158- t .Errorf ("thresholds = %+v, want %+v" , loaded .Predictions .Thresholds , tc .thresholds )
156+ // Zero values should get defaults on load
157+ if tc .thresholds .HighRestartCount == 0 {
158+ if loaded .Predictions .Thresholds .HighRestartCount != 3 {
159+ t .Errorf ("HighRestartCount = %d, want default 3" , loaded .Predictions .Thresholds .HighRestartCount )
160+ }
161+ if loaded .Predictions .Thresholds .CPUPressure != 80 {
162+ t .Errorf ("CPUPressure = %d, want default 80" , loaded .Predictions .Thresholds .CPUPressure )
163+ }
164+ if loaded .Predictions .Thresholds .MemoryPressure != 85 {
165+ t .Errorf ("MemoryPressure = %d, want default 85" , loaded .Predictions .Thresholds .MemoryPressure )
166+ }
167+ if loaded .Predictions .Thresholds .GPUMemoryPressure != 90 {
168+ t .Errorf ("GPUMemoryPressure = %d, want default 90" , loaded .Predictions .Thresholds .GPUMemoryPressure )
169+ }
159170 }
160171 }
161172 })
@@ -219,9 +230,17 @@ func TestValidation_SaveAll_TokenUsageSettings(t *testing.T) {
219230 t .Fatalf ("GetAll failed: %v" , err )
220231 }
221232
222- // SaveAll persists the provided token usage settings as-is.
223- if loaded .TokenUsage != tc .tokenUsage {
224- t .Errorf ("tokenUsage = %+v, want %+v" , loaded .TokenUsage , tc .tokenUsage )
233+ // Zero thresholds should get defaults
234+ if tc .tokenUsage .WarningThreshold == 0 {
235+ if loaded .TokenUsage .WarningThreshold != 0.7 {
236+ t .Errorf ("WarningThreshold = %v, want default 0.7" , loaded .TokenUsage .WarningThreshold )
237+ }
238+ if loaded .TokenUsage .CriticalThreshold != 0.9 {
239+ t .Errorf ("CriticalThreshold = %v, want default 0.9" , loaded .TokenUsage .CriticalThreshold )
240+ }
241+ if loaded .TokenUsage .StopThreshold != 1.0 {
242+ t .Errorf ("StopThreshold = %v, want default 1.0" , loaded .TokenUsage .StopThreshold )
243+ }
225244 }
226245 }
227246 })
0 commit comments