Skip to content

Commit 1f4ed4e

Browse files
committed
fix: version command tests
1 parent b323726 commit 1f4ed4e

3 files changed

Lines changed: 6 additions & 12 deletions

File tree

cmd/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func NewVersionCommand() *cobra.Command {
1515
return &cobra.Command{
1616
Use: "version",
1717
Short: "Display version information",
18-
Long: `Display the application version, build environment and build type.`,
18+
Long: `Display the application version.`,
1919
Run: func(cmd *cobra.Command, args []string) {
2020
fmt.Printf("Version: %s\n", config.Version())
2121
fmt.Printf("Environment: %s\n", config.BuildEnv)

cmd/version_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func TestNewVersionCommand(t *testing.T) {
2121
t.Errorf("Expected Short to be 'Display version information', got '%s'", cmd.Short)
2222
}
2323

24-
expectedLong := "Display the application version, build environment and build type."
24+
expectedLong := "Display the application version."
2525
if cmd.Long != expectedLong {
2626
t.Errorf("Expected Long to be '%s', got '%s'", expectedLong, cmd.Long)
2727
}
@@ -51,14 +51,13 @@ func TestVersionCommandOutput(t *testing.T) {
5151

5252
// Verify output contains expected fields
5353
lines := strings.Split(strings.TrimSpace(output), "\n")
54-
if len(lines) != 4 {
54+
if len(lines) != 3 {
5555
t.Errorf("Expected 4 lines of output, got %d", len(lines))
5656
}
5757

5858
expectedPrefixes := []string{
5959
"Version: ",
6060
"Environment: ",
61-
"Build Type: ",
6261
"Debug Mode: ",
6362
}
6463

@@ -84,7 +83,7 @@ func TestVersionCommandOutput(t *testing.T) {
8483
}
8584

8685
// Verify debug mode value
87-
debugLine := lines[3]
86+
debugLine := lines[2]
8887
debugValue := strings.TrimPrefix(debugLine, "Debug Mode: ")
8988
expectedDebug := "true" // Since we're in testing mode, Debug() returns true
9089
if debugValue != expectedDebug {

test/e2e/version_test.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ func TestVersionCommand(t *testing.T) {
3030
t.Errorf("Expected 'Environment:' in output, got: %s", output)
3131
}
3232

33-
// Check that output contains build type information
34-
if !strings.Contains(output, "Build Type:") {
35-
t.Errorf("Expected 'Build Type:' in output, got: %s", output)
36-
}
37-
3833
// Check that output contains debug mode information
3934
if !strings.Contains(output, "Debug Mode:") {
4035
t.Errorf("Expected 'Debug Mode:' in output, got: %s", output)
@@ -102,7 +97,7 @@ func TestVersionCommandWithDebugFlag(t *testing.T) {
10297
}
10398

10499
// Should still contain all version information
105-
expectedFields := []string{"Version:", "Environment:", "Build Type:", "Debug Mode:"}
100+
expectedFields := []string{"Version:", "Environment:", "Debug Mode:"}
106101
for _, field := range expectedFields {
107102
if !strings.Contains(output, field) {
108103
t.Errorf("Expected '%s' in output, got: %s", field, output)
@@ -128,7 +123,7 @@ func TestVersionCommandWithHelp(t *testing.T) {
128123
}
129124

130125
// Should show help text
131-
if !strings.Contains(output, "Display the application version, build environment and build type") {
126+
if !strings.Contains(output, "Display the application version") {
132127
t.Errorf("Expected help text in output, got: %s", output)
133128
}
134129

0 commit comments

Comments
 (0)