MCPcopy
hub / github.com/cli/cli / TestStartJupyterServerFailure

Function TestStartJupyterServerFailure

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

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