Functional Weave
Code in TypeScript

monitor.status-code-summary@1.0.0

vectors.json

2,951 bytes · view raw

[
  {"name": "a mixed batch: 2 server errors in 10 is 20%, the 404 is reported apart", "args": [[200, 201, 204, 301, 304, 404, 500, 503, 101, 200]], "expect": {"total": 10, "informational": 1, "success": 4, "redirect": 2, "clientError": 1, "serverError": 2, "errorRateBasisPoints": 2000, "clientErrorRateBasisPoints": 1000}},
  {"name": "an empty batch is all zeros, not a division by zero", "args": [[]], "expect": {"total": 0, "informational": 0, "success": 0, "redirect": 0, "clientError": 0, "serverError": 0, "errorRateBasisPoints": 0, "clientErrorRateBasisPoints": 0}},
  {"name": "every class boundary: 199 is informational, 299 success, 399 redirect, 499 client, 599 server", "args": [[100, 199, 200, 299, 300, 399, 400, 499, 500, 599]], "expect": {"total": 10, "informational": 2, "success": 2, "redirect": 2, "clientError": 2, "serverError": 2, "errorRateBasisPoints": 2000, "clientErrorRateBasisPoints": 2000}},
  {"name": "only server errors is 100%", "args": [[500, 502]], "expect": {"total": 2, "informational": 0, "success": 0, "redirect": 0, "clientError": 0, "serverError": 2, "errorRateBasisPoints": 10000, "clientErrorRateBasisPoints": 0}},
  {"name": "4xx is not a server error: 404s and a 429 leave the error rate at zero", "args": [[404, 404, 429, 200]], "expect": {"total": 4, "informational": 0, "success": 1, "redirect": 0, "clientError": 3, "serverError": 0, "errorRateBasisPoints": 0, "clientErrorRateBasisPoints": 7500}},
  {"name": "2 in 3 rounds half up to 6667", "args": [[500, 500, 200]], "expect": {"total": 3, "informational": 0, "success": 1, "redirect": 0, "clientError": 0, "serverError": 2, "errorRateBasisPoints": 6667, "clientErrorRateBasisPoints": 0}},
  {"name": "1 in 3 rounds down to 3333", "args": [[503, 200, 404]], "expect": {"total": 3, "informational": 0, "success": 1, "redirect": 0, "clientError": 1, "serverError": 1, "errorRateBasisPoints": 3333, "clientErrorRateBasisPoints": 3333}},
  {"name": "1 in 32 is exactly 312.5 and rounds up to 313", "args": [[500, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200]], "expect": {"total": 32, "informational": 0, "success": 31, "redirect": 0, "clientError": 0, "serverError": 1, "errorRateBasisPoints": 313, "clientErrorRateBasisPoints": 0}},
  {"name": "all success", "args": [[200, 200, 200, 200]], "expect": {"total": 4, "informational": 0, "success": 4, "redirect": 0, "clientError": 0, "serverError": 0, "errorRateBasisPoints": 0, "clientErrorRateBasisPoints": 0}},
  {"name": "600 is not an HTTP status code", "args": [[200, 600]], "expectError": "status code must be 100 to 599, received 600"},
  {"name": "99 is not an HTTP status code", "args": [[99]], "expectError": "status code must be 100 to 599, received 99"},
  {"name": "a fractional status code is an error", "args": [[200.5]], "expectError": "status code must be a whole number"}
]