Test that a simple string is returned via the Output helper, and that stderr is discarded.
(t *testing.T)
| 149 | // Test that a simple string is returned via the Output helper, |
| 150 | // and that stderr is discarded. |
| 151 | func 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. |
nothing calls this directly
no test coverage detected
searching dependent graphs…