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

Function TestStartJupyterServerSuccess

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

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