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

Function TestRebuildContainerFailure

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

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