MCPcopy
hub / github.com/spf13/cobra / TestUsageStringRedirected

Function TestUsageStringRedirected

command_test.go:2161–2175  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2159}
2160
2161func TestUsageStringRedirected(t *testing.T) {
2162 c := &Command{}
2163
2164 c.usageFunc = func(cmd *Command) error {
2165 cmd.Print("[stdout1]")
2166 cmd.PrintErr("[stderr2]")
2167 cmd.Print("[stdout3]")
2168 return nil
2169 }
2170
2171 expected := "[stdout1][stderr2][stdout3]"
2172 if got := c.UsageString(); got != expected {
2173 t.Errorf("Expected usage string to consider both stdout and stderr")
2174 }
2175}
2176
2177func TestCommandPrintRedirection(t *testing.T) {
2178 errBuff, outBuff := bytes.NewBuffer(nil), bytes.NewBuffer(nil)

Callers

nothing calls this directly

Calls 3

UsageStringMethod · 0.95
PrintMethod · 0.80
PrintErrMethod · 0.80

Tested by

no test coverage detected