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

Function TestStartJupyterServerSuccess

internal/codespaces/rpc/invoker_test.go:106–137  ·  view source on GitHub ↗

Test that the RPC invoker returns the correct port and URL when the JupyterLab server starts successfully

(t *testing.T)

Source from the content-addressed store, hash-verified

104
105// Test that the RPC invoker returns the correct port and URL when the JupyterLab server starts successfully
106func TestStartJupyterServerSuccess(t *testing.T) {
107 resp := jupyter.GetRunningServerResponse{
108 Port: strconv.Itoa(1234),
109 ServerUrl: "http://localhost:1234?token=1234",
110 Message: "",
111 Result: true,
112 }
113
114 server := newMockServer()
115 server.JupyterServerHostServerMock.GetRunningServerFunc = func(context.Context, *jupyter.GetRunningServerRequest) (*jupyter.GetRunningServerResponse, error) {
116 return &resp, nil
117 }
118
119 invoker, stop, err := createTestInvoker(t, server)
120 if err != nil {
121 t.Fatalf("error connecting to internal server: %v", err)
122 }
123 defer stop()
124
125 port, url, err := invoker.StartJupyterServer(context.Background())
126 if err != nil {
127 t.Fatalf("expected %v, got %v", nil, err)
128 }
129 if strconv.Itoa(port) != resp.Port {
130 t.Fatalf("expected %s, got %d", resp.Port, port)
131 }
132 if url != resp.ServerUrl {
133 t.Fatalf("expected %s, got %s", resp.ServerUrl, url)
134 }
135
136 verifyNotifyCodespaceOfClientActivity(t, server)
137}
138
139// Test that the RPC invoker returns an error when the JupyterLab server fails to start
140func TestStartJupyterServerFailure(t *testing.T) {

Callers

nothing calls this directly

Calls 4

newMockServerFunction · 0.85
createTestInvokerFunction · 0.85
StartJupyterServerMethod · 0.65

Tested by

no test coverage detected