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

Function TestRebuildContainerFailure

internal/codespaces/rpc/invoker_test.go:225–246  ·  view source on GitHub ↗

Test that the RPC invoker throws an error when the rebuild fails

(t *testing.T)

Source from the content-addressed store, hash-verified

223
224// Test that the RPC invoker throws an error when the rebuild fails
225func TestRebuildContainerFailure(t *testing.T) {
226 resp := codespace.RebuildContainerResponse{
227 RebuildContainer: false,
228 }
229
230 server := newMockServer()
231 server.RebuildContainerAsyncFunc = func(context.Context, *codespace.RebuildContainerRequest) (*codespace.RebuildContainerResponse, error) {
232 return &resp, nil
233 }
234
235 invoker, stop, err := createTestInvoker(t, server)
236 if err != nil {
237 t.Fatalf("error connecting to internal server: %v", err)
238 }
239 defer stop()
240
241 errorMessage := "couldn't rebuild codespace"
242 err = invoker.RebuildContainer(context.Background(), true)
243 if err.Error() != errorMessage {
244 t.Fatalf("expected %v, got %v", errorMessage, err)
245 }
246}
247
248// Test that the RPC invoker returns the correct port and user when the SSH server starts successfully
249func TestStartSSHServerSuccess(t *testing.T) {

Callers

nothing calls this directly

Calls 4

newMockServerFunction · 0.85
createTestInvokerFunction · 0.85
RebuildContainerMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected