['traffic_in']], 0, 300, 95, 0, $peak); } test('peak request returns the MAX based statistics when present', function () { $result = nth_percentile_with_stats([ 'avg' => ['traffic_in' => 100], 'peak' => ['traffic_in' => 250], ], true); expect($result)->toBe(['traffic_in' => 250]); }); test('peak request falls back to the AVERAGE statistics when the RRD has no MAX RRA', function () { // no MAX consolidation function: rrdtool_function_stats() emits 'peak' => [] $result = nth_percentile_with_stats([ 'avg' => ['traffic_in' => 100], 'peak' => [], ], true); expect($result)->toBe(['traffic_in' => 100]); }); test('peak request without any usable data returns an empty result', function () { expect(nth_percentile_with_stats([], true))->toBe([]); }); test('non-peak request still returns the AVERAGE statistics', function () { $result = nth_percentile_with_stats([ 'avg' => ['traffic_in' => 100], 'peak' => [], ], false); expect($result)->toBe(['traffic_in' => 100]); });