options.test.ts 873 B

1234567891011121314151617181920212223242526
  1. import { expect, test } from "bun:test"
  2. import { ServerOptions } from "@opencode-ai/server/options"
  3. import { Option, Schema } from "effect"
  4. const decode = Schema.decodeUnknownOption(ServerOptions)
  5. test("accepts ephemeral port zero", () => {
  6. expect(Option.isSome(decode({ port: 0 }))).toBe(true)
  7. })
  8. test("rejects ports outside the valid range", () => {
  9. expect(Option.isNone(decode({ port: -1 }))).toBe(true)
  10. expect(Option.isNone(decode({ port: 65_536 }))).toBe(true)
  11. })
  12. test("accepts optional app metadata", () => {
  13. expect(Option.getOrThrow(decode({ app: { name: "sdk", version: "1.2.3", channel: "beta" } })).app).toEqual({
  14. name: "sdk",
  15. version: "1.2.3",
  16. channel: "beta",
  17. })
  18. })
  19. test("accepts durable event persistence configuration", () => {
  20. expect(Option.getOrThrow(decode({ events: { persist: true } })).events).toEqual({ persist: true })
  21. })