Files
oh-my-opencode/src/hooks/runtime-fallback/auto-retry-signal.test.ts
T
wenghuayang863 f3f72fc96f fix(runtime-fallback): also classify Volcano Engine errors as quota_exceeded
- Add /exceeded.*quota/i and /usage\s*quota/i to classifyErrorType quota block
- Align /usage.?quota/i -> /usage\s*quota/i in RETRYABLE_ERROR_PATTERNS for consistency
- Strengthen auto-retry-signal test assertion
- Add classifyErrorType assertion to Volcano Engine regression test

Ensures Volcano Engine errors are both retryable AND logged as
errorType: quota_exceeded.
2026-05-11 01:03:02 +08:00

43 lines
1.1 KiB
TypeScript

import { describe, expect, test } from "bun:test"
import { extractAutoRetrySignal } from "./auto-retry-signal"
describe("extractAutoRetrySignal", () => {
test("detects Volcano Engine 'exceeded the usage quota' signal", () => {
//#given
const info = {
status: "You have exceeded the 5-hour usage quota. It will reset at 2026-05-11 01:20:12 +0800 CST.",
}
//#when
const signal = extractAutoRetrySignal(info)
//#then
expect(signal).toBeDefined()
expect(signal?.signal).toContain("exceeded")
expect(signal?.signal).toContain("usage quota")
})
test("detects standard 'quota exceeded' signal", () => {
//#given
const info = { message: "Quota exceeded for model gpt-4" }
//#when
const signal = extractAutoRetrySignal(info)
//#then
expect(signal).toBeDefined()
})
test("returns undefined for non-retryable info", () => {
//#given
const info = { message: "Something went wrong" }
//#when
const signal = extractAutoRetrySignal(info)
//#then
expect(signal).toBeUndefined()
})
})