@@ -442,6 +442,46 @@ func TestSetGlobalVersion_MultipleRuntimes(t *testing.T) {
442442 }
443443}
444444
445+ func TestGlobalVersion_NoConfigFile (t * testing.T ) {
446+ // On a clean system with no config file, GlobalVersion should return ("", nil)
447+ tmpRoot := t .TempDir ()
448+ t .Setenv ("HOME" , tmpRoot )
449+ t .Setenv ("USERPROFILE" , tmpRoot )
450+ ResetPathsCache ()
451+ defer ResetPathsCache ()
452+
453+ version , err := GlobalVersion ("python" )
454+ if err != nil {
455+ t .Errorf ("GlobalVersion() with no config file should return nil error, got: %v" , err )
456+ }
457+ if version != "" {
458+ t .Errorf ("GlobalVersion() with no config file should return empty string, got: %q" , version )
459+ }
460+ }
461+
462+ func TestGlobalVersion_RuntimeNotInConfig (t * testing.T ) {
463+ // When config exists but runtime is not in it, GlobalVersion should return ("", nil)
464+ tmpRoot := t .TempDir ()
465+ t .Setenv ("HOME" , tmpRoot )
466+ t .Setenv ("USERPROFILE" , tmpRoot )
467+ ResetPathsCache ()
468+ defer ResetPathsCache ()
469+
470+ // Set a version for python so the config file exists
471+ if err := SetGlobalVersion ("python" , "3.11.0" ); err != nil {
472+ t .Fatalf ("SetGlobalVersion() setup error: %v" , err )
473+ }
474+
475+ // Ask for node which is not in the config
476+ version , err := GlobalVersion ("node" )
477+ if err != nil {
478+ t .Errorf ("GlobalVersion() for missing runtime should return nil error, got: %v" , err )
479+ }
480+ if version != "" {
481+ t .Errorf ("GlobalVersion() for missing runtime should return empty string, got: %q" , version )
482+ }
483+ }
484+
445485func TestSetLocalVersion_CreatesDirectoryAndFile (t * testing.T ) {
446486 // Create temp directory and change to it
447487 tmpRoot := t .TempDir ()
0 commit comments