(t *testing.T)
| 215 | } |
| 216 | |
| 217 | func TestRCMetrics(t *testing.T) { |
| 218 | ctx := t.Context() |
| 219 | |
| 220 | tests := []struct { |
| 221 | name string |
| 222 | body string |
| 223 | expectedStatusCode int |
| 224 | expectedResponse string |
| 225 | expectedMetricsCount int |
| 226 | expectedOSName string |
| 227 | expectedOSVersion string |
| 228 | expectedFeatureFlags string |
| 229 | authType string |
| 230 | }{ |
| 231 | { |
| 232 | name: "empty metrics for RC", |
| 233 | body: `{ |
| 234 | }`, |
| 235 | expectedStatusCode: http.StatusBadRequest, |
| 236 | expectedResponse: "Missing remediation component data", |
| 237 | authType: APIKEY, |
| 238 | }, |
| 239 | { |
| 240 | name: "basic metrics with empty dynamic metrics for RC", |
| 241 | body: ` |
| 242 | { |
| 243 | "remediation_components": [ |
| 244 | { |
| 245 | "version": "1.42", |
| 246 | "os": {"name":"foo", "version": "42"}, |
| 247 | "utc_startup_timestamp": 42, |
| 248 | "metrics": [], |
| 249 | "feature_flags": ["a", "b", "c"] |
| 250 | } |
| 251 | ] |
| 252 | }`, |
| 253 | expectedStatusCode: http.StatusCreated, |
| 254 | expectedMetricsCount: 1, |
| 255 | expectedResponse: "", |
| 256 | expectedOSName: "foo", |
| 257 | expectedOSVersion: "42", |
| 258 | expectedFeatureFlags: "a,b,c", |
| 259 | authType: APIKEY, |
| 260 | }, |
| 261 | { |
| 262 | name: "basic metrics with dynamic metrics for RC", |
| 263 | body: ` |
| 264 | { |
| 265 | "remediation_components": [ |
| 266 | { |
| 267 | "version": "1.42", |
| 268 | "os": {"name":"foo", "version": "42"}, |
| 269 | "utc_startup_timestamp": 42, |
| 270 | "metrics": [{"meta":{"utc_now_timestamp":42, "window_size_seconds": 42}, "items": [{"name": "foo", "value": 42, "unit": "bla"}] }, {"meta":{"utc_now_timestamp":43, "window_size_seconds": 42}, "items": [{"name": "foo", "value": 42, "unit": "bla"}] }], |
| 271 | "feature_flags": ["a", "b", "c"] |
| 272 | } |
| 273 | ] |
| 274 | }`, |
nothing calls this directly
no test coverage detected
searching dependent graphs…