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

Function captureOutput

cmd/get/get_test.go:40–55  ·  view source on GitHub ↗

captureOutput captures stdout during the execution of fn.

(t *testing.T, fn func())

Source from the content-addressed store, hash-verified

38
39// captureOutput captures stdout during the execution of fn.
40func captureOutput(t *testing.T, fn func()) string {
41 t.Helper()
42 old := os.Stdout
43 r, w, err := os.Pipe()
44 assert.NoError(t, err)
45 os.Stdout = w
46
47 fn()
48
49 w.Close()
50 os.Stdout = old
51
52 var buf bytes.Buffer
53 buf.ReadFrom(r)
54 return buf.String()
55}
56
57func TestNewGetCommand_Structure(t *testing.T) {
58 cmd := NewGetCommand()

Calls 1

StringMethod · 0.80

Tested by

no test coverage detected