(t *testing.T)
| 32 | } |
| 33 | |
| 34 | func TestConvertResources(t *testing.T) { |
| 35 | t.Parallel() |
| 36 | // nolint:dogsled |
| 37 | _, filename, _, _ := runtime.Caller(0) |
| 38 | type testCase struct { |
| 39 | resources []*proto.Resource |
| 40 | parameters []*proto.RichParameter |
| 41 | Presets []*proto.Preset |
| 42 | externalAuthProviders []*proto.ExternalAuthProviderResource |
| 43 | } |
| 44 | |
| 45 | // If a user doesn't specify 'display_apps' then they default |
| 46 | // into all apps except VSCode Insiders. |
| 47 | displayApps := proto.DisplayApps{ |
| 48 | Vscode: true, |
| 49 | VscodeInsiders: false, |
| 50 | WebTerminal: true, |
| 51 | PortForwardingHelper: true, |
| 52 | SshHelper: true, |
| 53 | } |
| 54 | |
| 55 | // nolint:paralleltest |
| 56 | for folderName, expected := range map[string]testCase{ |
| 57 | // When a resource depends on another, the shortest route |
| 58 | // to a resource should always be chosen for the agent. |
| 59 | "chaining-resources": { |
| 60 | resources: []*proto.Resource{{ |
| 61 | Name: "a", |
| 62 | Type: "null_resource", |
| 63 | }, { |
| 64 | Name: "b", |
| 65 | Type: "null_resource", |
| 66 | Agents: []*proto.Agent{{ |
| 67 | Name: "main", |
| 68 | OperatingSystem: "linux", |
| 69 | Architecture: "amd64", |
| 70 | Auth: &proto.Agent_Token{}, |
| 71 | ApiKeyScope: "all", |
| 72 | ConnectionTimeoutSeconds: 120, |
| 73 | DisplayApps: &displayApps, |
| 74 | ResourcesMonitoring: &proto.ResourcesMonitoring{}, |
| 75 | }}, |
| 76 | }}, |
| 77 | }, |
| 78 | // This can happen when resources hierarchically conflict. |
| 79 | // When multiple resources exist at the same level, the first |
| 80 | // listed in state will be chosen. |
| 81 | "conflicting-resources": { |
| 82 | resources: []*proto.Resource{{ |
| 83 | Name: "first", |
| 84 | Type: "null_resource", |
| 85 | Agents: []*proto.Agent{{ |
| 86 | Name: "main", |
| 87 | OperatingSystem: "linux", |
| 88 | Architecture: "amd64", |
| 89 | Auth: &proto.Agent_Token{}, |
| 90 | ApiKeyScope: "all", |
| 91 | ConnectionTimeoutSeconds: 120, |
nothing calls this directly
no test coverage detected