@@ -425,6 +425,33 @@ func TestExecuteCommand_RequiresMountedSRTSettings(t *testing.T) {
425425 }
426426}
427427
428+ func TestCommandTimeout (t * testing.T ) {
429+ tests := []struct {
430+ name string
431+ envVal string
432+ command string
433+ want time.Duration
434+ }{
435+ {name : "default for generic command" , envVal : "" , command : "ls -la" , want : 30 * time .Second },
436+ {name : "default for python command" , envVal : "" , command : "python script.py" , want : 60 * time .Second },
437+ {name : "env override applies to generic" , envVal : "300" , command : "ls -la" , want : 300 * time .Second },
438+ {name : "env override applies to python too" , envVal : "300" , command : "python script.py" , want : 300 * time .Second },
439+ {name : "invalid env value falls back" , envVal : "notanumber" , command : "ls -la" , want : 30 * time .Second },
440+ {name : "zero env value falls back" , envVal : "0" , command : "ls -la" , want : 30 * time .Second },
441+ {name : "negative env value falls back" , envVal : "-5" , command : "ls -la" , want : 30 * time .Second },
442+ }
443+
444+ for _ , tt := range tests {
445+ t .Run (tt .name , func (t * testing.T ) {
446+ t .Setenv (commandTimeoutEnv , tt .envVal )
447+ got := commandTimeout (tt .command )
448+ if got != tt .want {
449+ t .Errorf ("commandTimeout(%q) with env=%q = %v, want %v" , tt .command , tt .envVal , got , tt .want )
450+ }
451+ })
452+ }
453+ }
454+
428455func TestExecuteCommand_Timeout (t * testing.T ) {
429456 // Skip this test if running in CI or if test timeout is too short
430457 // This test requires at least 35 seconds to run properly
0 commit comments