MCPcopy
hub / github.com/cli/cli / TestNewPortForwarder

Function TestNewPortForwarder

internal/codespaces/portforwarder/port_forwarder_test.go:15–47  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestNewPortForwarder(t *testing.T) {
16 ctx := context.Background()
17
18 // Create a mock codespace
19 codespace := &api.Codespace{
20 Connection: api.CodespaceConnection{
21 TunnelProperties: api.TunnelProperties{
22 ConnectAccessToken: "connect-token",
23 ManagePortsAccessToken: "manage-ports-token",
24 ServiceUri: "http://global.rel.tunnels.api.visualstudio.com/",
25 TunnelId: "tunnel-id",
26 ClusterId: "usw2",
27 Domain: "domain.com",
28 },
29 },
30 RuntimeConstraints: api.RuntimeConstraints{
31 AllowedPortPrivacySettings: []string{"public", "private"},
32 },
33 }
34
35 // Create the mock HTTP client
36 httpClient, err := connection.NewMockHttpClient()
37 require.NoError(t, err)
38
39 // Call the function being tested
40 conn, err := connection.NewCodespaceConnection(ctx, codespace, httpClient)
41 require.NoError(t, err)
42
43 // Create the new port forwarder
44 portForwarder, err := NewPortForwarder(ctx, conn)
45 require.NoError(t, err)
46 require.NotNil(t, portForwarder)
47}
48
49func TestAccessControlEntriesToVisibility(t *testing.T) {
50 publicAccessControlEntry := []tunnels.TunnelAccessControlEntry{{

Callers

nothing calls this directly

Calls 3

NewMockHttpClientFunction · 0.92
NewCodespaceConnectionFunction · 0.92
NewPortForwarderFunction · 0.85

Tested by

no test coverage detected