(t *testing.T)
| 79 | } |
| 80 | |
| 81 | func TestHealthcheck(t *testing.T) { |
| 82 | t.Parallel() |
| 83 | |
| 84 | for _, c := range []struct { |
| 85 | name string |
| 86 | checker *testChecker |
| 87 | healthy bool |
| 88 | severity health.Severity |
| 89 | }{ |
| 90 | { |
| 91 | name: "OK", |
| 92 | checker: healthyChecker(), |
| 93 | healthy: true, |
| 94 | severity: health.SeverityOK, |
| 95 | }, |
| 96 | { |
| 97 | name: "DERPFail", |
| 98 | checker: func() *testChecker { |
| 99 | c := healthyChecker() |
| 100 | c.DERPReport = healthsdk.DERPHealthReport{ |
| 101 | Healthy: false, |
| 102 | BaseReport: healthsdk.BaseReport{Severity: health.SeverityError}, |
| 103 | } |
| 104 | return c |
| 105 | }(), |
| 106 | healthy: false, |
| 107 | severity: health.SeverityError, |
| 108 | }, |
| 109 | { |
| 110 | name: "DERPWarning", |
| 111 | checker: func() *testChecker { |
| 112 | c := healthyChecker() |
| 113 | c.DERPReport = healthsdk.DERPHealthReport{ |
| 114 | Healthy: true, |
| 115 | BaseReport: healthsdk.BaseReport{ |
| 116 | Warnings: []health.Message{{Message: "foobar", Code: "EFOOBAR"}}, |
| 117 | Severity: health.SeverityWarning, |
| 118 | }, |
| 119 | } |
| 120 | return c |
| 121 | }(), |
| 122 | healthy: true, |
| 123 | severity: health.SeverityWarning, |
| 124 | }, |
| 125 | { |
| 126 | name: "AccessURLFail", |
| 127 | checker: func() *testChecker { |
| 128 | c := healthyChecker() |
| 129 | c.AccessURLReport = healthsdk.AccessURLReport{ |
| 130 | Healthy: false, |
| 131 | BaseReport: healthsdk.BaseReport{Severity: health.SeverityWarning}, |
| 132 | } |
| 133 | return c |
| 134 | }(), |
| 135 | healthy: false, |
| 136 | severity: health.SeverityWarning, |
| 137 | }, |
| 138 | { |
nothing calls this directly
no test coverage detected