(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func TestNewPortForwarder(t *testing.T) { |
| 13 | ctx := context.Background() |
| 14 | |
| 15 | // Create a mock codespace |
| 16 | codespace := &api.Codespace{ |
| 17 | Connection: api.CodespaceConnection{ |
| 18 | TunnelProperties: api.TunnelProperties{ |
| 19 | ConnectAccessToken: "connect-token", |
| 20 | ManagePortsAccessToken: "manage-ports-token", |
| 21 | ServiceUri: "http://global.rel.tunnels.api.visualstudio.com/", |
| 22 | TunnelId: "tunnel-id", |
| 23 | ClusterId: "usw2", |
| 24 | Domain: "domain.com", |
| 25 | }, |
| 26 | }, |
| 27 | RuntimeConstraints: api.RuntimeConstraints{ |
| 28 | AllowedPortPrivacySettings: []string{"public", "private"}, |
| 29 | }, |
| 30 | } |
| 31 | |
| 32 | // Create the mock HTTP client |
| 33 | httpClient, err := connection.NewMockHttpClient() |
| 34 | if err != nil { |
| 35 | t.Fatalf("NewHttpClient returned an error: %v", err) |
| 36 | } |
| 37 | |
| 38 | // Call the function being tested |
| 39 | conn, err := connection.NewCodespaceConnection(ctx, codespace, httpClient) |
| 40 | if err != nil { |
| 41 | t.Fatalf("NewCodespaceConnection returned an error: %v", err) |
| 42 | } |
| 43 | |
| 44 | // Create the new port forwarder |
| 45 | portForwarder, err := NewPortForwarder(ctx, conn) |
| 46 | if err != nil { |
| 47 | t.Fatalf("NewPortForwarder returned an error: %v", err) |
| 48 | } |
| 49 | |
| 50 | // Check that the port forwarder was created successfully |
| 51 | if portForwarder == nil { |
| 52 | t.Fatal("NewPortForwarder returned nil") |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | func TestAccessControlEntriesToVisibility(t *testing.T) { |
| 57 | publicAccessControlEntry := []tunnels.TunnelAccessControlEntry{{ |
nothing calls this directly
no test coverage detected