MCPcopy
hub / github.com/cli/cli / GetMockApi

Function GetMockApi

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

Source from the content-addressed store, hash-verified

128}
129
130func GetMockApi(allowOrgPorts bool) *apiClientMock {
131 return &apiClientMock{
132 GetCodespaceFunc: func(ctx context.Context, codespaceName string, includeConnection bool) (*api.Codespace, error) {
133 allowedPortPrivacySettings := []string{"public", "private"}
134 if allowOrgPorts {
135 allowedPortPrivacySettings = append(allowedPortPrivacySettings, "org")
136 }
137
138 return &api.Codespace{
139 Name: "codespace-name",
140 State: api.CodespaceStateAvailable,
141 Connection: api.CodespaceConnection{
142 TunnelProperties: api.TunnelProperties{
143 ConnectAccessToken: "tunnel access-token",
144 ManagePortsAccessToken: "manage-ports-token",
145 ServiceUri: "http://global.rel.tunnels.api.visualstudio.com/",
146 TunnelId: "tunnel-id",
147 ClusterId: "usw2",
148 Domain: "domain.com",
149 },
150 },
151 RuntimeConstraints: api.RuntimeConstraints{
152 AllowedPortPrivacySettings: allowedPortPrivacySettings,
153 },
154 }, nil
155 },
156 StartCodespaceFunc: func(ctx context.Context, codespaceName string) error {
157 return nil
158 },
159 GetCodespaceRepositoryContentsFunc: func(ctx context.Context, codespace *api.Codespace, path string) ([]byte, error) {
160 return nil, nil
161 },
162 ExternalHTTPClientFunc: func() (*http.Client, error) {
163 return connection.NewMockHttpClient()
164 },
165 }
166}
167
168func testingPortsApp() *App {
169 disabledCodespace := &api.Codespace{

Callers 2

TestListPortsFunction · 0.85
runUpdateVisibilityTestFunction · 0.85

Calls 1

NewMockHttpClientFunction · 0.92

Tested by

no test coverage detected