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

Function TestNewVersionCommand_PartialFieldsSet

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

Source from the content-addressed store, hash-verified

91}
92
93func TestNewVersionCommand_PartialFieldsSet(t *testing.T) {
94 // Save and restore original values
95 origVersion := Version
96 origBuildGoVersion := BuildGoVersion
97 origBuildTime := BuildTime
98 defer func() {
99 Version = origVersion
100 BuildGoVersion = origBuildGoVersion
101 BuildTime = origBuildTime
102 }()
103
104 Version = "0.9.0"
105 BuildGoVersion = ""
106 BuildTime = ""
107
108 cmd := NewVersionCommand()
109
110 // Capture stdout
111 old := os.Stdout
112 r, w, _ := os.Pipe()
113 os.Stdout = w
114
115 cmd.Run(cmd, []string{})
116
117 w.Close()
118 os.Stdout = old
119
120 var buf bytes.Buffer
121 buf.ReadFrom(r)
122 output := buf.String()
123
124 assert.Contains(t, output, "Version: 0.9.0")
125 assert.NotContains(t, output, "GoVersion:")
126 assert.NotContains(t, output, "BuildTime:")
127}
128
129func TestNewVersionCommand_OnlyGoVersionSet(t *testing.T) {
130 origVersion := Version

Callers

nothing calls this directly

Calls 2

NewVersionCommandFunction · 0.85
StringMethod · 0.80

Tested by

no test coverage detected