refactor(core): move database schema ownership (#29068)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
import { describe, expect, test } from "bun:test"
|
||||
import { SessionLegacy } from "@opencode-ai/core/session/legacy"
|
||||
import { Exit, Schema } from "effect"
|
||||
import { MessageV2 } from "../../src/session/message-v2"
|
||||
import { SessionPrompt } from "../../src/session/prompt"
|
||||
import { SessionID, MessageID } from "../../src/session/schema"
|
||||
|
||||
const decodeFormat = Schema.decodeUnknownExit(MessageV2.Format)
|
||||
const decodeUser = Schema.decodeUnknownExit(MessageV2.User)
|
||||
const decodeAssistant = Schema.decodeUnknownExit(MessageV2.Assistant)
|
||||
const decodeFormat = Schema.decodeUnknownExit(SessionLegacy.Format)
|
||||
const decodeUser = Schema.decodeUnknownExit(SessionLegacy.User)
|
||||
const decodeAssistant = Schema.decodeUnknownExit(SessionLegacy.Assistant)
|
||||
|
||||
describe("structured-output.OutputFormat", () => {
|
||||
test("parses text format", () => {
|
||||
@@ -65,7 +66,7 @@ describe("structured-output.OutputFormat", () => {
|
||||
|
||||
describe("structured-output.StructuredOutputError", () => {
|
||||
test("creates error with message and retries", () => {
|
||||
const error = new MessageV2.StructuredOutputError({
|
||||
const error = new SessionLegacy.StructuredOutputError({
|
||||
message: "Failed to validate",
|
||||
retries: 3,
|
||||
})
|
||||
@@ -76,7 +77,7 @@ describe("structured-output.StructuredOutputError", () => {
|
||||
})
|
||||
|
||||
test("converts to object correctly", () => {
|
||||
const error = new MessageV2.StructuredOutputError({
|
||||
const error = new SessionLegacy.StructuredOutputError({
|
||||
message: "Test error",
|
||||
retries: 2,
|
||||
})
|
||||
@@ -88,13 +89,13 @@ describe("structured-output.StructuredOutputError", () => {
|
||||
})
|
||||
|
||||
test("isInstance correctly identifies error", () => {
|
||||
const error = new MessageV2.StructuredOutputError({
|
||||
const error = new SessionLegacy.StructuredOutputError({
|
||||
message: "Test",
|
||||
retries: 1,
|
||||
})
|
||||
|
||||
expect(MessageV2.StructuredOutputError.isInstance(error)).toBe(true)
|
||||
expect(MessageV2.StructuredOutputError.isInstance({ name: "other" })).toBe(false)
|
||||
expect(SessionLegacy.StructuredOutputError.isInstance(error)).toBe(true)
|
||||
expect(SessionLegacy.StructuredOutputError.isInstance({ name: "other" })).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user