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

Function GetMockApi

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

Source from the content-addressed store, hash-verified

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

Callers 2

TestListPortsFunction · 0.85
runUpdateVisibilityTestFunction · 0.85

Calls 1

NewMockHttpClientFunction · 0.92

Tested by

no test coverage detected