(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func TestWorkspaceProxies(t *testing.T) { |
| 15 | t.Parallel() |
| 16 | |
| 17 | for _, tt := range []struct { |
| 18 | name string |
| 19 | fetchWorkspaceProxies func(context.Context) (codersdk.RegionsResponse[codersdk.WorkspaceProxy], error) |
| 20 | updateProxyHealth func(context.Context) error |
| 21 | expectedHealthy bool |
| 22 | expectedError string |
| 23 | expectedWarningCode health.Code |
| 24 | expectedSeverity health.Severity |
| 25 | }{ |
| 26 | { |
| 27 | name: "NotEnabled", |
| 28 | expectedHealthy: true, |
| 29 | expectedSeverity: health.SeverityOK, |
| 30 | }, |
| 31 | { |
| 32 | name: "Enabled/NoProxies", |
| 33 | fetchWorkspaceProxies: fakeFetchWorkspaceProxies(), |
| 34 | updateProxyHealth: fakeUpdateProxyHealth(nil), |
| 35 | expectedHealthy: true, |
| 36 | expectedSeverity: health.SeverityOK, |
| 37 | }, |
| 38 | { |
| 39 | name: "Enabled/OneHealthy", |
| 40 | fetchWorkspaceProxies: fakeFetchWorkspaceProxies(fakeWorkspaceProxy("alpha", true)), |
| 41 | updateProxyHealth: fakeUpdateProxyHealth(nil), |
| 42 | expectedHealthy: true, |
| 43 | expectedSeverity: health.SeverityOK, |
| 44 | }, |
| 45 | { |
| 46 | name: "Enabled/OneUnhealthy", |
| 47 | fetchWorkspaceProxies: fakeFetchWorkspaceProxies(fakeWorkspaceProxy("alpha", false)), |
| 48 | updateProxyHealth: fakeUpdateProxyHealth(nil), |
| 49 | expectedHealthy: false, |
| 50 | expectedSeverity: health.SeverityError, |
| 51 | expectedError: string(health.CodeProxyUnhealthy), |
| 52 | }, |
| 53 | { |
| 54 | name: "Enabled/OneUnreachable", |
| 55 | fetchWorkspaceProxies: func(ctx context.Context) (codersdk.RegionsResponse[codersdk.WorkspaceProxy], error) { |
| 56 | return codersdk.RegionsResponse[codersdk.WorkspaceProxy]{ |
| 57 | Regions: []codersdk.WorkspaceProxy{ |
| 58 | { |
| 59 | Region: codersdk.Region{ |
| 60 | Name: "gone", |
| 61 | Healthy: false, |
| 62 | }, |
| 63 | Status: codersdk.WorkspaceProxyStatus{ |
| 64 | Status: codersdk.ProxyUnreachable, |
| 65 | Report: codersdk.ProxyHealthReport{ |
| 66 | Errors: []string{ |
| 67 | "request to proxy failed: Get \"http://127.0.0.1:3001/healthz-report\": dial tcp 127.0.0.1:3001: connect: connection refused", |
| 68 | }, |
| 69 | }, |
| 70 | }, |
| 71 | }, |
nothing calls this directly
no test coverage detected