Something went wrong. Try again.
opencode v2 mirror
Something went wrong. Try again.
TypeScript
12345678910111213141516171819202122232425262728293031323334353637383940414243444546import { describe, expect } from "bun:test"import { Effect, Layer } from "effect"import { AppNodeBuilder } from "@opencode/core/effect/app-node-builder"import { Location } from "@opencode/core/location"import { Project } from "@opencode/core/project"import { AbsolutePath } from "@opencode/core/schema"import { Workspace } from "@opencode/core/workspace"import { testEffect } from "./lib/effect"
const workspaceID = Workspace.ID.make("wrk_test")const ref = { directory: AbsolutePath.make("/repo/packages/app"), workspaceID }const projectLayer = Layer.succeed( Project.Service, Project.Service.of({ list: () => Effect.succeed([]), update: () => Effect.die("not implemented"), activate: () => Effect.void, resolve: () => Effect.succeed({ id: Project.ID.make("project"), directory: AbsolutePath.make("/repo"), canonical: AbsolutePath.make("/main/repo"), vcs: { type: "git", store: AbsolutePath.make("/repo/.git") }, }), }),)const it = testEffect(AppNodeBuilder.build(Location.boundNode(ref), [Project.node.replace(projectLayer)]))
describe("Location", () => { it.effect("resolves the current project and vcs information", () => Effect.gen(function* () { const location = yield* Location.Service
expect(location.directory).toBe(AbsolutePath.make("/repo/packages/app")) expect(location.workspaceID).toBe(workspaceID) expect(location.project.id).toBe(Project.ID.make("project")) expect(location.project.directory).toBe(AbsolutePath.make("/repo")) expect(location.project.canonical).toBe(AbsolutePath.make("/main/repo")) expect(location.vcs).toEqual({ type: "git", store: AbsolutePath.make("/repo/.git"), }) }), )})