mirror of
https://github.com/stablyai/orca.git
synced 2026-09-25 00:02:35 +00:00
* 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
27 lines
915 B
TypeScript
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)
|
|
})
|