()
| 93 | } |
| 94 | |
| 95 | func testViewApiMock() *apiClientMock { |
| 96 | codespaceWithNoDetails := &api.Codespace{ |
| 97 | Name: "monalisa-cli-cli-abcdef", |
| 98 | } |
| 99 | codespaceWithDetails := &api.Codespace{ |
| 100 | Name: "monalisa-cli-cli-hijklm", |
| 101 | GitStatus: api.CodespaceGitStatus{ |
| 102 | Ahead: 1, |
| 103 | Behind: 2, |
| 104 | Ref: "main", |
| 105 | HasUnpushedChanges: true, |
| 106 | HasUncommittedChanges: true, |
| 107 | }, |
| 108 | IdleTimeoutMinutes: 30, |
| 109 | RetentionPeriodMinutes: 1440, |
| 110 | State: "Available", |
| 111 | Repository: api.Repository{FullName: "cli/cli"}, |
| 112 | DevContainerPath: ".devcontainer/devcontainer.json", |
| 113 | Machine: api.CodespaceMachine{ |
| 114 | DisplayName: "Test Display Name", |
| 115 | }, |
| 116 | } |
| 117 | return &apiClientMock{ |
| 118 | GetCodespaceFunc: func(_ context.Context, name string, _ bool) (*api.Codespace, error) { |
| 119 | if name == codespaceWithDetails.Name { |
| 120 | return codespaceWithDetails, nil |
| 121 | } else if name == codespaceWithNoDetails.Name { |
| 122 | return codespaceWithNoDetails, nil |
| 123 | } |
| 124 | |
| 125 | return nil, fmt.Errorf("codespace not found") |
| 126 | }, |
| 127 | ListCodespacesFunc: func(ctx context.Context, opts api.ListCodespacesOptions) ([]*api.Codespace, error) { |
| 128 | return []*api.Codespace{codespaceWithNoDetails, codespaceWithDetails}, nil |
| 129 | }, |
| 130 | } |
| 131 | } |
no test coverage detected