MCPcopy
hub / github.com/cli/cli / TestStartSSHServerSuccess

Function TestStartSSHServerSuccess

internal/codespaces/rpc/invoker_test.go:249–280  ·  view source on GitHub ↗

Test that the RPC invoker returns the correct port and user when the SSH server starts successfully

(t *testing.T)

Source from the content-addressed store, hash-verified

247
248// Test that the RPC invoker returns the correct port and user when the SSH server starts successfully
249func TestStartSSHServerSuccess(t *testing.T) {
250 resp := ssh.StartRemoteServerResponse{
251 ServerPort: strconv.Itoa(1234),
252 User: "test",
253 Message: "",
254 Result: true,
255 }
256
257 server := newMockServer()
258 server.StartRemoteServerAsyncFunc = func(context.Context, *ssh.StartRemoteServerRequest) (*ssh.StartRemoteServerResponse, error) {
259 return &resp, nil
260 }
261
262 invoker, stop, err := createTestInvoker(t, server)
263 if err != nil {
264 t.Fatalf("error connecting to internal server: %v", err)
265 }
266 defer stop()
267
268 port, user, err := invoker.StartSSHServer(context.Background())
269 if err != nil {
270 t.Fatalf("expected %v, got %v", nil, err)
271 }
272 if strconv.Itoa(port) != resp.ServerPort {
273 t.Fatalf("expected %s, got %d", resp.ServerPort, port)
274 }
275 if user != resp.User {
276 t.Fatalf("expected %s, got %s", resp.User, user)
277 }
278
279 verifyNotifyCodespaceOfClientActivity(t, server)
280}
281
282// Test that the RPC invoker returns an error when the SSH server fails to start
283func TestStartSSHServerFailure(t *testing.T) {

Callers

nothing calls this directly

Calls 4

newMockServerFunction · 0.85
createTestInvokerFunction · 0.85
StartSSHServerMethod · 0.65

Tested by

no test coverage detected