@@ -14,27 +14,27 @@ func TestVersionCommand(t *testing.T) {
1414
1515 // Execute the version command
1616 output , err := execCommand (t , []string {"version" }, homeDir )
17-
17+
1818 // Version command should always succeed
1919 if err != nil {
2020 t .Errorf ("Version command failed with error: %v" , err )
2121 }
22-
22+
2323 // Check that output contains version information
2424 if ! strings .Contains (output , "Version:" ) {
2525 t .Errorf ("Expected 'Version:' in output, got: %s" , output )
2626 }
27-
27+
2828 // Check that output contains environment information
2929 if ! strings .Contains (output , "Environment:" ) {
3030 t .Errorf ("Expected 'Environment:' in output, got: %s" , output )
3131 }
32-
32+
3333 // Check that output contains build type information
3434 if ! strings .Contains (output , "Build Type:" ) {
3535 t .Errorf ("Expected 'Build Type:' in output, got: %s" , output )
3636 }
37-
37+
3838 // Check that output contains debug mode information
3939 if ! strings .Contains (output , "Debug Mode:" ) {
4040 t .Errorf ("Expected 'Debug Mode:' in output, got: %s" , output )
@@ -48,47 +48,41 @@ func TestVersionCommandFormat(t *testing.T) {
4848
4949 // Execute the version command
5050 output , err := execCommand (t , []string {"version" }, homeDir )
51-
51+
5252 if err != nil {
5353 t .Errorf ("Version command failed with error: %v" , err )
5454 }
55-
55+
5656 lines := strings .Split (strings .TrimSpace (output ), "\n " )
57-
57+
5858 // Should have exactly 4 lines of output
5959 if len (lines ) != 4 {
6060 t .Errorf ("Expected 4 lines of output, got %d lines: %s" , len (lines ), output )
6161 }
62-
62+
6363 // Check version format (should be like "Version: 0.0.1+0")
6464 versionLine := lines [0 ]
6565 if ! strings .HasPrefix (versionLine , "Version: " ) {
6666 t .Errorf ("First line should start with 'Version: ', got: %s" , versionLine )
6767 }
68-
68+
6969 versionValue := strings .TrimPrefix (versionLine , "Version: " )
7070 if ! strings .Contains (versionValue , "." ) || ! strings .Contains (versionValue , "+" ) {
7171 t .Errorf ("Version should be in format 'major.minor.patch+build', got: %s" , versionValue )
7272 }
73-
73+
7474 // Check environment line
7575 envLine := lines [1 ]
7676 if ! strings .HasPrefix (envLine , "Environment: " ) {
7777 t .Errorf ("Second line should start with 'Environment: ', got: %s" , envLine )
7878 }
79-
80- // Check build type line
81- buildTypeLine := lines [2 ]
82- if ! strings .HasPrefix (buildTypeLine , "Build Type: " ) {
83- t .Errorf ("Third line should start with 'Build Type: ', got: %s" , buildTypeLine )
84- }
85-
79+
8680 // Check debug mode line
8781 debugLine := lines [3 ]
8882 if ! strings .HasPrefix (debugLine , "Debug Mode: " ) {
8983 t .Errorf ("Fourth line should start with 'Debug Mode: ', got: %s" , debugLine )
9084 }
91-
85+
9286 debugValue := strings .TrimPrefix (debugLine , "Debug Mode: " )
9387 if debugValue != "true" && debugValue != "false" {
9488 t .Errorf ("Debug Mode should be 'true' or 'false', got: %s" , debugValue )
@@ -102,19 +96,19 @@ func TestVersionCommandWithDebugFlag(t *testing.T) {
10296
10397 // Execute the version command with debug flag
10498 output , err := execCommand (t , []string {"version" , "--debug" }, homeDir )
105-
99+
106100 if err != nil {
107101 t .Errorf ("Version command with debug flag failed with error: %v" , err )
108102 }
109-
103+
110104 // Should still contain all version information
111105 expectedFields := []string {"Version:" , "Environment:" , "Build Type:" , "Debug Mode:" }
112106 for _ , field := range expectedFields {
113107 if ! strings .Contains (output , field ) {
114108 t .Errorf ("Expected '%s' in output, got: %s" , field , output )
115109 }
116110 }
117-
111+
118112 // When debug flag is used, debug mode should be true
119113 if ! strings .Contains (output , "Debug Mode: true" ) {
120114 t .Errorf ("Expected 'Debug Mode: true' when using --debug flag, got: %s" , output )
@@ -128,17 +122,17 @@ func TestVersionCommandWithHelp(t *testing.T) {
128122
129123 // Execute the version command with help flag
130124 output , err := execCommand (t , []string {"version" , "--help" }, homeDir )
131-
125+
132126 if err != nil {
133127 t .Errorf ("Version command with help flag failed with error: %v" , err )
134128 }
135-
129+
136130 // Should show help text
137131 if ! strings .Contains (output , "Display the application version, build environment and build type" ) {
138132 t .Errorf ("Expected help text in output, got: %s" , output )
139133 }
140-
134+
141135 if ! strings .Contains (output , "Usage:" ) {
142136 t .Errorf ("Expected usage information in output, got: %s" , output )
143137 }
144- }
138+ }
0 commit comments