MCPcopy Create free account
hub / github.com/cli/cli / GetMockApi

Function GetMockApi

pkg/cmd/codespace/ports_test.go:165–201  ·  view source on GitHub ↗
(allowOrgPorts bool)

Source from the content-addressed store, hash-verified

163}
164
165func 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
203func testingPortsApp() *App {
204 disabledCodespace := &api.Codespace{

Callers 3

TestListPortsFunction · 0.85
runUpdateVisibilityTestFunction · 0.85

Calls 1

NewMockHttpClientFunction · 0.92

Tested by

no test coverage detected