Files
orca/cloud/apps/push/src/push-readiness.test.ts
Jinwoo Hong eb2f2d52ae feat(cloud): native push gateway and dedicated infrastructure (1/3) (#19912)
* refactor(cloud): share PostgreSQL schema startup between services

* feat(cloud): add durable native push notification gateway

* infra(push): define dedicated gateway resources and operational checks

* fix(push): bound cross-host admission and simplify gateway configuration

* fix(push): validate deploy configuration and preserve topic-error registrations
2026-09-10 17:59:46 -04:00

27 lines
915 B
TypeScript

import { expect, it, vi } from 'vitest'
import { createPushReadiness } from './push-readiness.js'
import type { PushDatabase } from './push-database.js'
it('shares a slow check and caches failures before retrying', async () => {
let clock = 0
let reject!: (error: Error) => void
const query = vi.fn(
() =>
new Promise<never>((_, fail) => {
reject = fail
})
)
const ready = createPushReadiness({ query } as unknown as PushDatabase, { now: () => clock })
const checks = Array.from({ length: 100 }, () => ready())
expect(query).toHaveBeenCalledTimes(1)
reject(new Error('offline'))
expect(await Promise.all(checks)).toEqual(Array(100).fill(false))
expect(await ready()).toBe(false)
expect(query).toHaveBeenCalledTimes(1)
clock = 10_000
const retry = ready()
expect(query).toHaveBeenCalledTimes(2)
reject(new Error('offline'))
expect(await retry).toBe(false)
})