@@ -3,26 +3,26 @@ package cmd
33import (
44 "testing"
55
6- "github.com/Malwarebytes/mbvpn/pkg/errors"
6+ "github.com/Malwarebytes/mbvpn-linux /pkg/errors"
77 "github.com/spf13/cobra"
88)
99
1010func TestRootCommandStructure (t * testing.T ) {
1111 if rootCmd .Use != "mbvpn" {
1212 t .Errorf ("Expected Use to be 'mbvpn', got '%s'" , rootCmd .Use )
1313 }
14-
14+
1515 if rootCmd .Short != "Malwarebytes VPN command-line client" {
1616 t .Errorf ("Expected Short to be 'Malwarebytes VPN command-line client', got '%s'" , rootCmd .Short )
1717 }
18-
18+
1919 expectedLong := `MBVPN is a command-line VPN client for Malwarebytes VPN service.
2020Manage your VPN connections, browse available servers, and control
2121your privacy settings from the terminal. Requires a valid Malwarebytes license.`
2222 if rootCmd .Long != expectedLong {
2323 t .Errorf ("Expected Long to be '%s', got '%s'" , expectedLong , rootCmd .Long )
2424 }
25-
25+
2626 if rootCmd .PersistentPreRun == nil {
2727 t .Error ("Expected PersistentPreRun function to be defined" )
2828 }
@@ -38,7 +38,7 @@ func TestRootCommandFlags(t *testing.T) {
3838 t .Errorf ("Expected debug flag usage to be 'Run command in debug mode.', got '%s'" , debugFlag .Usage )
3939 }
4040 }
41-
41+
4242 // Test trace flag
4343 traceFlag := rootCmd .PersistentFlags ().Lookup ("trace" )
4444 if traceFlag == nil {
@@ -52,7 +52,7 @@ func TestRootCommandFlags(t *testing.T) {
5252
5353func TestRootCommandSubcommands (t * testing.T ) {
5454 expectedCommands := []string {"login" , "logout" , "servers" , "countries" , "cities" , "connect" , "disconnect" , "status" , "version" }
55-
55+
5656 for _ , expectedCmd := range expectedCommands {
5757 found := false
5858 for _ , cmd := range rootCmd .Commands () {
@@ -70,15 +70,15 @@ func TestRootCommandSubcommands(t *testing.T) {
7070func TestPersistentPreRunInitializesErrorHandler (t * testing.T ) {
7171 // Create a simple test command with the same PersistentPreRun
7272 testCmd := & cobra.Command {
73- Use : "test" ,
73+ Use : "test" ,
7474 PersistentPreRun : rootCmd .PersistentPreRun ,
7575 }
7676 testCmd .PersistentFlags ().Bool ("debug" , false , "Run command in debug mode." )
7777 testCmd .PersistentFlags ().Bool ("trace" , false , "Run command in trace mode." )
78-
78+
7979 // Execute PersistentPreRun
8080 testCmd .PersistentPreRun (testCmd , []string {})
81-
81+
8282 // Verify ErrorHandler is initialized
8383 if ErrorHandler == nil {
8484 t .Error ("Expected ErrorHandler to be initialized" )
@@ -88,7 +88,7 @@ func TestPersistentPreRunInitializesErrorHandler(t *testing.T) {
8888func TestHandleErrorWithNilError (t * testing.T ) {
8989 // Initialize ErrorHandler
9090 ErrorHandler = errors .NewHandler ()
91-
91+
9292 // Test with nil error - should not panic or exit
9393 HandleError (nil )
9494 // If we reach this point, the function handled nil correctly
@@ -97,13 +97,13 @@ func TestHandleErrorWithNilError(t *testing.T) {
9797func TestHandleErrorWithNilHandler (t * testing.T ) {
9898 // Test error handling when ErrorHandler is nil
9999 ErrorHandler = nil
100-
100+
101101 // We can't test the actual os.Exit behavior, but we can verify the function exists
102102 // and would handle the fallback case
103103 if ErrorHandler != nil {
104104 t .Error ("Expected ErrorHandler to be nil for this test" )
105105 }
106-
106+
107107 // Reset ErrorHandler for other tests
108108 ErrorHandler = errors .NewHandler ()
109- }
109+ }
0 commit comments