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

Function TestNewVersionCommand_AllFieldsSet

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

Source from the content-addressed store, hash-verified

20}
21
22func TestNewVersionCommand_AllFieldsSet(t *testing.T) {
23 // Save and restore original values
24 origVersion := Version
25 origBuildGoVersion := BuildGoVersion
26 origBuildTime := BuildTime
27 defer func() {
28 Version = origVersion
29 BuildGoVersion = origBuildGoVersion
30 BuildTime = origBuildTime
31 }()
32
33 Version = "1.2.3"
34 BuildGoVersion = "go1.25.0"
35 BuildTime = "2024-01-01"
36
37 cmd := NewVersionCommand()
38
39 // Capture stdout
40 old := os.Stdout
41 r, w, _ := os.Pipe()
42 os.Stdout = w
43
44 cmd.Run(cmd, []string{})
45
46 w.Close()
47 os.Stdout = old
48
49 var buf bytes.Buffer
50 buf.ReadFrom(r)
51 output := buf.String()
52
53 assert.Contains(t, output, "Version: 1.2.3")
54 assert.Contains(t, output, "GoVersion: go1.25.0")
55 assert.Contains(t, output, "BuildTime: 2024-01-01")
56}
57
58func TestNewVersionCommand_EmptyFields(t *testing.T) {
59 // Save and restore original values

Callers

nothing calls this directly

Calls 2

NewVersionCommandFunction · 0.85
StringMethod · 0.80

Tested by

no test coverage detected