MCPcopy
hub / github.com/tailscale/tailscale / TestSessionOutput

Function TestSessionOutput

tempfork/sshtest/ssh/session_test.go:151–171  ·  view source on GitHub ↗

Test that a simple string is returned via the Output helper, and that stderr is discarded.

(t *testing.T)

Source from the content-addressed store, hash-verified

149// Test that a simple string is returned via the Output helper,
150// and that stderr is discarded.
151func TestSessionOutput(t *testing.T) {
152 conn := dial(fixedOutputHandler, t)
153 defer conn.Close()
154 session, err := conn.NewSession()
155 if err != nil {
156 t.Fatalf("Unable to request new session: %v", err)
157 }
158 defer session.Close()
159
160 buf, err := session.Output("") // cmd is ignored by fixedOutputHandler
161 if err != nil {
162 t.Error("Remote command did not exit cleanly:", err)
163 }
164 w := "this-is-stdout."
165 g := string(buf)
166 if g != w {
167 t.Error("Remote command did not return expected string:")
168 t.Logf("want %q", w)
169 t.Logf("got %q", g)
170 }
171}
172
173// Test that both stdout and stderr are returned
174// via the CombinedOutput helper.

Callers

nothing calls this directly

Calls 8

CloseMethod · 0.95
OutputMethod · 0.95
dialFunction · 0.85
NewSessionMethod · 0.80
CloseMethod · 0.65
FatalfMethod · 0.65
ErrorMethod · 0.65
LogfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…