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

Function TestStartJupyterServerFailure

internal/codespaces/rpc/invoker_test.go:141–173  ·  view source on GitHub ↗

Test that the RPC invoker returns an error when the JupyterLab server fails to start

(t *testing.T)

Source from the content-addressed store, hash-verified

139
140// Test that the RPC invoker returns an error when the JupyterLab server fails to start
141func TestStartJupyterServerFailure(t *testing.T) {
142 resp := jupyter.GetRunningServerResponse{
143 Port: strconv.Itoa(1234),
144 ServerUrl: "http://localhost:1234?token=1234",
145 Message: "error message",
146 Result: false,
147 }
148
149 server := newMockServer()
150 server.JupyterServerHostServerMock.GetRunningServerFunc = func(context.Context, *jupyter.GetRunningServerRequest) (*jupyter.GetRunningServerResponse, error) {
151 return &resp, nil
152 }
153
154 invoker, stop, err := createTestInvoker(t, server)
155 if err != nil {
156 t.Fatalf("error connecting to internal server: %v", err)
157 }
158 defer stop()
159
160 errorMessage := fmt.Sprintf("failed to start JupyterLab: %s", resp.Message)
161 port, url, err := invoker.StartJupyterServer(context.Background())
162 if err.Error() != errorMessage {
163 t.Fatalf("expected %v, got %v", errorMessage, err)
164 }
165 if port != 0 {
166 t.Fatalf("expected %d, got %d", 0, port)
167 }
168 if url != "" {
169 t.Fatalf("expected %s, got %s", "", url)
170 }
171
172 verifyNotifyCodespaceOfClientActivity(t, server)
173}
174
175// Test that the RPC invoker doesn't throw an error when requesting an incremental rebuild
176func TestRebuildContainerIncremental(t *testing.T) {

Callers

nothing calls this directly

Calls 5

newMockServerFunction · 0.85
createTestInvokerFunction · 0.85
StartJupyterServerMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…