MCPcopy Create free account
hub / github.com/Driver-C/tryssh / TestNewVersionCommand_EmptyFields

Function TestNewVersionCommand_EmptyFields

cmd/version/version_test.go:58–91  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

56}
57
58func TestNewVersionCommand_EmptyFields(t *testing.T) {
59 // Save and restore original values
60 origVersion := Version
61 origBuildGoVersion := BuildGoVersion
62 origBuildTime := BuildTime
63 defer func() {
64 Version = origVersion
65 BuildGoVersion = origBuildGoVersion
66 BuildTime = origBuildTime
67 }()
68
69 Version = ""
70 BuildGoVersion = ""
71 BuildTime = ""
72
73 cmd := NewVersionCommand()
74
75 // Capture stdout
76 old := os.Stdout
77 r, w, _ := os.Pipe()
78 os.Stdout = w
79
80 cmd.Run(cmd, []string{})
81
82 w.Close()
83 os.Stdout = old
84
85 var buf bytes.Buffer
86 buf.ReadFrom(r)
87 output := buf.String()
88
89 assert.Contains(t, output, "(dev)",
90 "output should show (dev) when all fields are empty")
91}
92
93func TestNewVersionCommand_PartialFieldsSet(t *testing.T) {
94 // Save and restore original values

Callers

nothing calls this directly

Calls 2

NewVersionCommandFunction · 0.85
StringMethod · 0.80

Tested by

no test coverage detected