refactor(failover-tests): share observation base
This commit is contained in:
parent
4db3fed299
commit
774b351982
@ -1,21 +1,31 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { normalizeFailoverDecisionObservationBase } from "./failover-observation.js";
|
||||
|
||||
function normalizeObservation(
|
||||
overrides: Partial<Parameters<typeof normalizeFailoverDecisionObservationBase>[0]>,
|
||||
) {
|
||||
return normalizeFailoverDecisionObservationBase({
|
||||
stage: "assistant",
|
||||
runId: "run:base",
|
||||
rawError: "",
|
||||
failoverReason: null,
|
||||
profileFailureReason: null,
|
||||
provider: "openai",
|
||||
model: "mock-1",
|
||||
profileId: "openai:p1",
|
||||
fallbackConfigured: false,
|
||||
timedOut: false,
|
||||
aborted: false,
|
||||
...overrides,
|
||||
});
|
||||
}
|
||||
|
||||
describe("normalizeFailoverDecisionObservationBase", () => {
|
||||
it("fills timeout observation reasons for deadline timeouts without provider error text", () => {
|
||||
expect(
|
||||
normalizeFailoverDecisionObservationBase({
|
||||
stage: "assistant",
|
||||
normalizeObservation({
|
||||
runId: "run:timeout",
|
||||
rawError: "",
|
||||
failoverReason: null,
|
||||
profileFailureReason: null,
|
||||
provider: "openai",
|
||||
model: "mock-1",
|
||||
profileId: "openai:p1",
|
||||
fallbackConfigured: false,
|
||||
timedOut: true,
|
||||
aborted: false,
|
||||
}),
|
||||
).toMatchObject({
|
||||
failoverReason: "timeout",
|
||||
@ -26,18 +36,13 @@ describe("normalizeFailoverDecisionObservationBase", () => {
|
||||
|
||||
it("preserves explicit failover reasons", () => {
|
||||
expect(
|
||||
normalizeFailoverDecisionObservationBase({
|
||||
stage: "assistant",
|
||||
normalizeObservation({
|
||||
runId: "run:overloaded",
|
||||
rawError: '{"error":{"type":"overloaded_error"}}',
|
||||
failoverReason: "overloaded",
|
||||
profileFailureReason: "overloaded",
|
||||
provider: "openai",
|
||||
model: "mock-1",
|
||||
profileId: "openai:p1",
|
||||
fallbackConfigured: true,
|
||||
timedOut: true,
|
||||
aborted: false,
|
||||
}),
|
||||
).toMatchObject({
|
||||
failoverReason: "overloaded",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user