feat: publish v1.0.0-rc.36-custom.1
This commit is contained in:
commit
3a7e8f3b54
2381 files changed
+551494
No files matched your search
@@ -0,0 +1,70 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import {
|
||||
cacheHitRates,
|
||||
formatCacheHitRate,
|
||||
getOverallStatus,
|
||||
getProbeInterval,
|
||||
statusKind,
|
||||
} from '../lib/status'
|
||||
|
||||
describe('group status mapping', () => {
|
||||
it('maps down monitors to error', () => {
|
||||
expect(statusKind(0)).toBe('error')
|
||||
})
|
||||
|
||||
it('uses the most severe monitor state for the summary', () => {
|
||||
expect(getOverallStatus([1, 2, 0])).toBe('error')
|
||||
})
|
||||
|
||||
it('derives the probe interval from recent heartbeats', () => {
|
||||
expect(
|
||||
getProbeInterval([
|
||||
{ status: 1, time: '2026-09-05 10:05:00' },
|
||||
{ status: 1, time: '2026-09-05 10:11:00' },
|
||||
])
|
||||
).toBe(6)
|
||||
})
|
||||
|
||||
it('keeps missing samples unknown instead of reporting an outage', () => {
|
||||
expect(statusKind(-1)).toBe('unknown')
|
||||
expect(cacheHitRates()).toEqual({ request: null, token: null })
|
||||
})
|
||||
|
||||
it('does not replace the normal interval with one restart sample', () => {
|
||||
expect(
|
||||
getProbeInterval([
|
||||
{ status: 1, time: '2026-09-05 10:00:00' },
|
||||
{ status: 1, time: '2026-09-05 10:06:00' },
|
||||
{ status: 1, time: '2026-09-05 10:12:00' },
|
||||
{ status: 1, time: '2026-09-05 10:13:00' },
|
||||
])
|
||||
).toBe(6)
|
||||
})
|
||||
|
||||
it('uses request counts and total input tokens as different denominators', () => {
|
||||
expect(
|
||||
cacheHitRates({
|
||||
requests: 4,
|
||||
cached_requests: 3,
|
||||
input_tokens: 1000,
|
||||
cached_tokens: 900,
|
||||
})
|
||||
).toEqual({ request: 0.75, token: 0.9 })
|
||||
expect(
|
||||
cacheHitRates({
|
||||
requests: 4,
|
||||
cached_requests: 0,
|
||||
input_tokens: 1000,
|
||||
cached_tokens: 0,
|
||||
})
|
||||
).toEqual({ request: 0, token: 0 })
|
||||
})
|
||||
|
||||
it('does not round a near-perfect cache rate up to 100 percent', () => {
|
||||
expect(formatCacheHitRate(381763 / 381785)).toBe('99.99%')
|
||||
expect(formatCacheHitRate(706457 / 706572)).toBe('99.98%')
|
||||
expect(formatCacheHitRate(2 / 3)).toBe('66.7%')
|
||||
expect(formatCacheHitRate(1)).toBe('100.0%')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user