MCPcopy Index your code
hub / github.com/cli/cli / TestStartSSHServerSuccess

Function TestStartSSHServerSuccess

internal/codespaces/rpc/invoker_test.go:250–281  ·  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

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