refactor(client): simplify local service lifecycle
This commit is contained in:
parent
4f1298063b
commit
75bc611ef1
51 changed files with 635 additions and 534 deletions
|
|
@ -1,4 +1,3 @@
|
|||
import { InstallationVersion } from "@opencode-ai/core/installation/version"
|
||||
import { expect } from "bun:test"
|
||||
import { Effect } from "effect"
|
||||
import { it } from "../../core/test/lib/effect"
|
||||
|
|
@ -16,14 +15,10 @@ it.effect("moves from starting to ready", () =>
|
|||
it.effect("keeps a startup failure until shutdown", () =>
|
||||
Effect.gen(function* () {
|
||||
const status = yield* Status.make({ instanceID: "one", managed: true })
|
||||
yield* status.fail({ message: "Could not open the database.", action: "Check the database path." })
|
||||
yield* status.fail
|
||||
yield* status.ready
|
||||
yield* status.fail({ message: "Different failure.", action: "Different action." })
|
||||
expect(yield* status.current).toEqual({
|
||||
type: "failed",
|
||||
message: "Could not open the database.",
|
||||
action: "Check the database path.",
|
||||
})
|
||||
yield* status.fail
|
||||
expect(yield* status.current).toEqual({ type: "failed" })
|
||||
}),
|
||||
)
|
||||
|
||||
|
|
@ -31,21 +26,20 @@ it.effect("stops only the addressed managed instance", () =>
|
|||
Effect.gen(function* () {
|
||||
const status = yield* Status.make({ instanceID: "one", managed: true })
|
||||
|
||||
expect(yield* status.requestStop({ instanceID: "other", targetVersion: "next" })).toBe(false)
|
||||
expect(yield* status.requestStop({ instanceID: "other" })).toBe(false)
|
||||
expect(yield* status.current).toEqual({ type: "starting" })
|
||||
expect(yield* status.requestStop({ instanceID: "one", targetVersion: "next" })).toBe(true)
|
||||
expect(yield* status.requestStop({ instanceID: "one", targetVersion: InstallationVersion })).toBe(true)
|
||||
expect(yield* status.current).toEqual({ type: "stopping", targetVersion: "next" })
|
||||
expect(yield* status.requestStop({ instanceID: "one" })).toBe(true)
|
||||
expect(yield* status.current).toEqual({ type: "stopping" })
|
||||
}),
|
||||
)
|
||||
|
||||
it.effect("preserves the original stopping target after shutdown begins", () =>
|
||||
it.effect("keeps stopping after shutdown begins", () =>
|
||||
Effect.gen(function* () {
|
||||
const status = yield* Status.make({ instanceID: "one", managed: true })
|
||||
|
||||
yield* status.beginStopping("next")
|
||||
expect(yield* status.current).toEqual({ type: "stopping", targetVersion: "next" })
|
||||
yield* status.beginStopping
|
||||
expect(yield* status.current).toEqual({ type: "stopping" })
|
||||
expect(yield* status.requestStop({ instanceID: "one" })).toBe(true)
|
||||
expect(yield* status.current).toEqual({ type: "stopping", targetVersion: "next" })
|
||||
expect(yield* status.current).toEqual({ type: "stopping" })
|
||||
}),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue