options.test.ts 867 B

123456789101112131415161718192021222324
  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(
  14. Option.getOrThrow(decode({ app: { name: "sdk", version: "1.2.3", channel: "beta" } })).app,
  15. ).toEqual({ name: "sdk", version: "1.2.3", channel: "beta" })
  16. })
  17. test("accepts durable event persistence configuration", () => {
  18. expect(Option.getOrThrow(decode({ events: { persist: true } })).events).toEqual({ persist: true })
  19. })