(allowOrgPorts bool)
| 163 | } |
| 164 | |
| 165 | func GetMockApi(allowOrgPorts bool) *apiClientMock { |
| 166 | return &apiClientMock{ |
| 167 | GetCodespaceFunc: func(ctx context.Context, codespaceName string, includeConnection bool) (*api.Codespace, error) { |
| 168 | allowedPortPrivacySettings := []string{"public", "private"} |
| 169 | if allowOrgPorts { |
| 170 | allowedPortPrivacySettings = append(allowedPortPrivacySettings, "org") |
| 171 | } |
| 172 | |
| 173 | return &api.Codespace{ |
| 174 | Name: "codespace-name", |
| 175 | State: api.CodespaceStateAvailable, |
| 176 | Connection: api.CodespaceConnection{ |
| 177 | TunnelProperties: api.TunnelProperties{ |
| 178 | ConnectAccessToken: "tunnel access-token", |
| 179 | ManagePortsAccessToken: "manage-ports-token", |
| 180 | ServiceUri: "http://global.rel.tunnels.api.visualstudio.com/", |
| 181 | TunnelId: "tunnel-id", |
| 182 | ClusterId: "usw2", |
| 183 | Domain: "domain.com", |
| 184 | }, |
| 185 | }, |
| 186 | RuntimeConstraints: api.RuntimeConstraints{ |
| 187 | AllowedPortPrivacySettings: allowedPortPrivacySettings, |
| 188 | }, |
| 189 | }, nil |
| 190 | }, |
| 191 | StartCodespaceFunc: func(ctx context.Context, codespaceName string) error { |
| 192 | return nil |
| 193 | }, |
| 194 | GetCodespaceRepositoryContentsFunc: func(ctx context.Context, codespace *api.Codespace, path string) ([]byte, error) { |
| 195 | return nil, nil |
| 196 | }, |
| 197 | ExternalHTTPClientFunc: func() (*http.Client, error) { |
| 198 | return connection.NewMockHttpClient() |
| 199 | }, |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | func testingPortsApp() *App { |
| 204 | disabledCodespace := &api.Codespace{ |
no test coverage detected