[ {"name": "three days of up: two full days and today up to now", "args": [[{"at": 1727827200, "status": "up"}], 1728003600, 3, 259200], "expect": [{"date": "2024-10-02", "uptimeBasisPoints": 10000, "upSeconds": 86400, "degradedSeconds": 0, "downSeconds": 0, "unknownSeconds": 0, "state": "operational"}, {"date": "2024-10-03", "uptimeBasisPoints": 10000, "upSeconds": 86400, "degradedSeconds": 0, "downSeconds": 0, "unknownSeconds": 0, "state": "operational"}, {"date": "2024-10-04", "uptimeBasisPoints": 10000, "upSeconds": 3600, "degradedSeconds": 0, "downSeconds": 0, "unknownSeconds": 0, "state": "operational"}]}, {"name": "an hour down shows an outage bar at 95.83%, a slow hour a degraded bar at 100%", "args": [[{"at": 1727827200, "status": "up"}, {"at": 1727870400, "status": "down"}, {"at": 1727874000, "status": "up"}, {"at": 1727935200, "status": "degraded"}, {"at": 1727938800, "status": "up"}], 1728007200, 3, 86400], "expect": [{"date": "2024-10-02", "uptimeBasisPoints": 9583, "upSeconds": 82800, "degradedSeconds": 0, "downSeconds": 3600, "unknownSeconds": 0, "state": "outage"}, {"date": "2024-10-03", "uptimeBasisPoints": 10000, "upSeconds": 82800, "degradedSeconds": 3600, "downSeconds": 0, "unknownSeconds": 0, "state": "degraded"}, {"date": "2024-10-04", "uptimeBasisPoints": 10000, "upSeconds": 7200, "degradedSeconds": 0, "downSeconds": 0, "unknownSeconds": 0, "state": "operational"}]}, {"name": "days with no checks are no-data bars, not operational ones", "args": [[], 1728000100, 2, 60], "expect": [{"date": "2024-10-03", "uptimeBasisPoints": null, "upSeconds": 0, "degradedSeconds": 0, "downSeconds": 0, "unknownSeconds": 86400, "state": "no-data"}, {"date": "2024-10-04", "uptimeBasisPoints": null, "upSeconds": 0, "degradedSeconds": 0, "downSeconds": 0, "unknownSeconds": 100, "state": "no-data"}]}, {"name": "at exactly midnight today's bar is empty and no-data", "args": [[{"at": 1727913600, "status": "up"}], 1728000000, 2, 86400], "expect": [{"date": "2024-10-03", "uptimeBasisPoints": 10000, "upSeconds": 86400, "degradedSeconds": 0, "downSeconds": 0, "unknownSeconds": 0, "state": "operational"}, {"date": "2024-10-04", "uptimeBasisPoints": null, "upSeconds": 0, "degradedSeconds": 0, "downSeconds": 0, "unknownSeconds": 0, "state": "no-data"}]}, {"name": "one day: a check from before midnight carries into today", "args": [[{"at": 1727999940, "status": "down"}, {"at": 1728000060, "status": "up"}], 1728000120, 1, 300], "expect": [{"date": "2024-10-04", "uptimeBasisPoints": 5000, "upSeconds": 60, "degradedSeconds": 0, "downSeconds": 60, "unknownSeconds": 0, "state": "outage"}]}, {"name": "unknown time alone does not make a bar degraded", "args": [[{"at": 1728000000, "status": "up"}], 1728001000, 1, 600], "expect": [{"date": "2024-10-04", "uptimeBasisPoints": 10000, "upSeconds": 600, "degradedSeconds": 0, "downSeconds": 0, "unknownSeconds": 400, "state": "operational"}]}, {"name": "before 1970 the day is floored, so today starts at the earlier midnight", "args": [[{"at": -100000, "status": "up"}], -1, 2, 200000], "expect": [{"date": "1969-12-30", "uptimeBasisPoints": 10000, "upSeconds": 13600, "degradedSeconds": 0, "downSeconds": 0, "unknownSeconds": 72800, "state": "operational"}, {"date": "1969-12-31", "uptimeBasisPoints": 10000, "upSeconds": 86399, "degradedSeconds": 0, "downSeconds": 0, "unknownSeconds": 0, "state": "operational"}]}, {"name": "down outranks degraded on the same day; uptime floors 2/3 to 6666", "args": [[{"at": 1728000000, "status": "degraded"}, {"at": 1728000100, "status": "down"}, {"at": 1728000200, "status": "up"}], 1728000300, 1, 100], "expect": [{"date": "2024-10-04", "uptimeBasisPoints": 6666, "upSeconds": 100, "degradedSeconds": 100, "downSeconds": 100, "unknownSeconds": 0, "state": "outage"}]}, {"name": "checks after now are ignored", "args": [[{"at": 1728000000, "status": "up"}, {"at": 1728000500, "status": "down"}], 1728000100, 1, 1000], "expect": [{"date": "2024-10-04", "uptimeBasisPoints": 10000, "upSeconds": 100, "degradedSeconds": 0, "downSeconds": 0, "unknownSeconds": 0, "state": "operational"}]}, {"name": "a down check at 23:59:59 marks only that day", "args": [[{"at": 1727999999, "status": "down"}, {"at": 1728000000, "status": "up"}], 1728000010, 2, 60], "expect": [{"date": "2024-10-03", "uptimeBasisPoints": 0, "upSeconds": 0, "degradedSeconds": 0, "downSeconds": 1, "unknownSeconds": 86399, "state": "outage"}, {"date": "2024-10-04", "uptimeBasisPoints": 10000, "upSeconds": 10, "degradedSeconds": 0, "downSeconds": 0, "unknownSeconds": 0, "state": "operational"}]}, {"name": "zero days is an error", "args": [[], 1728000000, 0, 60], "expectError": "days must be 1 to 366, received 0"}, {"name": "more than 366 days is an error", "args": [[], 1728000000, 367, 60], "expectError": "days must be 1 to 366, received 367"}, {"name": "a fractional day count is an error", "args": [[], 1728000000, 1.5, 60], "expectError": "days must be 1 to 366, received 1.5"}, {"name": "a fractional now is an error", "args": [[], 0.5, 1, 60], "expectError": "now must be whole seconds"}, {"name": "a maxGapSeconds of zero is an error", "args": [[], 1728000000, 1, 0], "expectError": "maxGapSeconds must be a whole number of at least 1, received 0"}, {"name": "misordered checks are an error", "args": [[{"at": 1728000000, "status": "up"}, {"at": 1727999995, "status": "up"}], 1728000010, 1, 60], "expectError": "checks must be in strictly ascending time order: 1727999995 follows 1728000000"}, {"name": "an unknown status is an error", "args": [[{"at": 1728000000, "status": "offline"}], 1728000010, 1, 60], "expectError": "unknown check status: offline"} ]