@@ -326,6 +326,63 @@ func TestReconcile_OwnerReferenceSet(t *testing.T) {
326326 }
327327}
328328
329+ // ─────────────────────────────────────────────────────────────────────────────
330+ // vkContainerArgs helper
331+ // ─────────────────────────────────────────────────────────────────────────────
332+
333+ func TestVkContainerArgs_NoLogLevel (t * testing.T ) {
334+ args := vkContainerArgs ("router-x" , "" )
335+ for _ , a := range args {
336+ if a == "--log-level" {
337+ t .Fatal ("--log-level should not be present when logLevel is empty" )
338+ }
339+ }
340+ if args [0 ] != "run" {
341+ t .Errorf ("expected first arg 'run', got %q" , args [0 ])
342+ }
343+ }
344+
345+ func TestVkContainerArgs_WithLogLevel (t * testing.T ) {
346+ args := vkContainerArgs ("router-x" , "debug" )
347+ found := false
348+ for i , a := range args {
349+ if a == "--log-level" && i + 1 < len (args ) && args [i + 1 ] == "debug" {
350+ found = true
351+ break
352+ }
353+ }
354+ if ! found {
355+ t .Errorf ("expected --log-level debug in args, got %v" , args )
356+ }
357+ }
358+
359+ func TestReconcile_LogLevelPassedToDeployment (t * testing.T ) {
360+ device := newDevice ("router-ll" , "default" )
361+ device .Spec .LogLevel = "debug"
362+ r := reconcilerFor (t , device )
363+ ctx := context .Background ()
364+
365+ if _ , err := r .Reconcile (ctx , reconcileRequest ("default" , "router-ll" )); err != nil {
366+ t .Fatalf ("Reconcile error: %v" , err )
367+ }
368+
369+ var deploy appsv1.Deployment
370+ if err := r .Get (ctx , types.NamespacedName {Namespace : "default" , Name : "router-ll" + deploymentSuffix }, & deploy ); err != nil {
371+ t .Fatalf ("Deployment not found: %v" , err )
372+ }
373+ args := deploy .Spec .Template .Spec .Containers [0 ].Args
374+ found := false
375+ for i , a := range args {
376+ if a == "--log-level" && i + 1 < len (args ) && args [i + 1 ] == "debug" {
377+ found = true
378+ break
379+ }
380+ }
381+ if ! found {
382+ t .Errorf ("expected --log-level debug in container args, got %v" , args )
383+ }
384+ }
385+
329386// ─────────────────────────────────────────────────────────────────────────────
330387// Pure helper: renderDeviceConfig
331388// ─────────────────────────────────────────────────────────────────────────────
0 commit comments