@@ -460,3 +460,52 @@ func BenchmarkJetbrainsCommand_ParseIDEFromDirName(b *testing.B) {
460460 }
461461 }
462462}
463+
464+ func TestJetbrainsCommand_DetectJetBrainsIDEs_WithTestAppData (t * testing.T ) {
465+ // Test TEST_APPDATA support for Windows testing environments
466+
467+ // Create temporary directory for TEST_APPDATA
468+ tempDir := t .TempDir ()
469+
470+ // Create mock JetBrains configuration directory structure
471+ jetbrainsDir := filepath .Join (tempDir , "JetBrains" )
472+ ideaDir := filepath .Join (jetbrainsDir , "IntelliJIdea2023.3" )
473+ err := os .MkdirAll (ideaDir , 0755 )
474+ require .NoError (t , err )
475+
476+ // Create mock idea.properties file
477+ propertiesPath := filepath .Join (ideaDir , "idea.properties" )
478+ propertiesContent := "# Test properties\n ide.system.path=${user.home}/.local/share/JetBrains/IntelliJIdea2023.3\n "
479+ err = os .WriteFile (propertiesPath , []byte (propertiesContent ), 0644 )
480+ require .NoError (t , err )
481+
482+ // Set TEST_APPDATA environment variable
483+ originalTestAppData := os .Getenv ("TEST_APPDATA" )
484+ defer func () {
485+ if originalTestAppData != "" {
486+ _ = os .Setenv ("TEST_APPDATA" , originalTestAppData )
487+ } else {
488+ _ = os .Unsetenv ("TEST_APPDATA" )
489+ }
490+ }()
491+ err = os .Setenv ("TEST_APPDATA" , tempDir )
492+ require .NoError (t , err )
493+
494+ // Create JetBrains command and test detection
495+ cmd := & JetbrainsCommand {}
496+
497+ // For testing, temporarily modify runtime.GOOS to simulate Windows behavior
498+ // Note: We can't actually change runtime.GOOS, so this test documents the intended behavior
499+ if runtime .GOOS == "windows" {
500+ // Run detection - should find our mock IDE
501+ err = cmd .detectJetBrainsIDEs ()
502+ // Should succeed when TEST_APPDATA points to our mock directory
503+ require .NoError (t , err )
504+ require .Len (t , cmd .detectedIDEs , 1 )
505+ require .Equal (t , "IntelliJ IDEA" , cmd .detectedIDEs [0 ].Name )
506+ require .Equal (t , "2023.3" , cmd .detectedIDEs [0 ].Version )
507+ } else {
508+ // On non-Windows, TEST_APPDATA should not affect detection
509+ t .Logf ("TEST_APPDATA test is primarily for Windows environments" )
510+ }
511+ }
0 commit comments